]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #885 - Aaron1011:fix/f-round, r=RalfJung
authorbors <bors@rust-lang.org>
Sun, 4 Aug 2019 20:12:02 +0000 (20:12 +0000)
committerbors <bors@rust-lang.org>
Sun, 4 Aug 2019 20:12:02 +0000 (20:12 +0000)
Add misssing 'roundf32' and 'roundf64' intrinsics

README.md
src/helpers.rs

index 91fc72cb427bcef6102fd4fc0f20e40c5769d848..8c5a29880c7cbfd464a752bc9983cb7147ba1665 100644 (file)
--- a/README.md
+++ b/README.md
@@ -342,6 +342,7 @@ Definite bugs found:
 * [`str` turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/58200)
 * [`rand` performing unaligned reads](https://github.com/rust-random/rand/issues/779)
 * [The Unix allocator calling `posix_memalign` in an invalid way](https://github.com/rust-lang/rust/issues/62251)
+* [`getrandom` calling the `getrandom` syscall in an invalid way](https://github.com/rust-random/getrandom/pull/73)
 
 Violations of Stacked Borrows found that are likely bugs (but Stacked Borrows is currently just an experiment):
 
index e9b09d8160567e818e42f77461558952f02ba90d..c0e1ec2cd75bceaf202b57f8d9672d2fb19a8678 100644 (file)
@@ -81,12 +81,21 @@ fn gen_random(
         ptr: Scalar<Tag>,
         len: usize,
     ) -> InterpResult<'tcx>  {
+        // Some programs pass in a null pointer and a length of 0
+        // to their platform's random-generation function (e.g. getrandom())
+        // on Linux. For compatibility with these programs, we don't perform
+        // any additional checks - it's okay if the pointer is invalid,
+        // since we wouldn't actually be writing to it.
+        if len == 0 {
+            return Ok(());
+        }
         let this = self.eval_context_mut();
 
-        let ptr = match this.memory().check_ptr_access(ptr, Size::from_bytes(len as u64), Align::from_bytes(1).unwrap())? {
-            Some(ptr) => ptr,
-            None => return Ok(()), // zero-sized access
-        };
+        let ptr = this.memory().check_ptr_access(
+            ptr,
+            Size::from_bytes(len as u64),
+            Align::from_bytes(1).unwrap()
+        )?.expect("we already checked for size 0");
 
         let rng = this.memory_mut().extra.rng.get_mut();
         let mut data = vec![0; len];