diff options
| author | bors <bors@rust-lang.org> | 2019-08-08 17:19:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-08 17:19:22 +0000 |
| commit | 2d1a551e144335e0d60a637d12f410cf65849876 (patch) | |
| tree | 48a18f5e5415a6fc9736a5ff12c497b2ed2b51f5 /src/libstd/sys | |
| parent | 2628f579f6246df385acf9203bf2ffb6aedf5ccc (diff) | |
| parent | 3de450b6865f5ba717b196054b231b16f67b2c17 (diff) | |
| download | rust-2d1a551e144335e0d60a637d12f410cf65849876.tar.gz rust-2d1a551e144335e0d60a637d12f410cf65849876.zip | |
Auto merge of #63380 - Centril:rollup-tzfhtnu, r=Centril
Rollup of 8 pull requests Successful merges: - #63261 (bump rand in libcore/liballoc test suites) - #63316 (Update rustfmt to 1.4.4) - #63332 (Add an overflow check in truncate implementation for Unix.) - #63342 (Don't use remap-path-prefix in dep-info files.) - #63366 (doc: Fix typo in float from bytes methods) - #63370 (Fix ICE #63364) - #63377 (Improved documentation for compile_error!()) - #63379 (Add test for issue 53096) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 822feacea62..3b1eb86b84f 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -557,9 +557,15 @@ impl File { return crate::sys::android::ftruncate64(self.0.raw(), size); #[cfg(not(target_os = "android"))] - return cvt_r(|| unsafe { - ftruncate64(self.0.raw(), size as off64_t) - }).map(|_| ()); + { + use crate::convert::TryInto; + let size: off64_t = size + .try_into() + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; + cvt_r(|| unsafe { + ftruncate64(self.0.raw(), size) + }).map(|_| ()) + } } pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { |
