Snap for 7168215 from cf398cf7b4f431ba3e78abbc4b34df8f2d1e562f to simpleperf-release

Change-Id: Ifca3558a08314403c7640ca898670ab8232ea208
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 0db4f9b..3fd44e0 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "98e220c30234370fb04ba928799ebd9727fc049a"
+    "sha1": "3a03c9eb5350e03a3f540dba2ee34e0984f2c2c2"
   }
 }
diff --git a/Android.bp b/Android.bp
index c5526ed..b0e0717 100644
--- a/Android.bp
+++ b/Android.bp
@@ -36,6 +36,9 @@
 rust_test_host {
     name: "rand_core_host_test_src_lib",
     defaults: ["rand_core_defaults"],
+    test_options: {
+        unit_test: true,
+    },
 }
 
 rust_test {
@@ -44,6 +47,6 @@
 }
 
 // dependent_library ["feature_list"]
-//   cfg-if-0.1.10
-//   getrandom-0.2.0 "std"
-//   libc-0.2.81
+//   cfg-if-1.0.0
+//   getrandom-0.2.2 "std"
+//   libc-0.2.86
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63a8bb8..23d1fa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [0.6.2] - 2021-02-12
+### Fixed
+- Fixed assertions in `le::read_u32_into` and `le::read_u64_into` which could
+  have allowed buffers not to be fully populated (#1096)
+
+## [0.6.1] - 2021-01-03
+### Fixed
+- Avoid panic when using `RngCore::seed_from_u64` with a seed which is not a
+  multiple of four (#1082)
+### Other
+- Enable all stable features in the playground (#1081)
+
 ## [0.6.0] - 2020-12-08
 ### Breaking changes
 - Bump MSRV to 1.36, various code improvements (#1011)
diff --git a/Cargo.toml b/Cargo.toml
index 508f993..51b8385 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,11 +13,11 @@
 [package]
 edition = "2018"
 name = "rand_core"
-version = "0.6.0"
+version = "0.6.2"
 authors = ["The Rand Project Developers", "The Rust Project Developers"]
 description = "Core random number generator traits and tools for implementation.\n"
-homepage = "https://crates.io/crates/rand_core"
-documentation = "https://rust-random.github.io/rand/rand_core/"
+homepage = "https://rust-random.github.io/book"
+documentation = "https://docs.rs/rand_core"
 readme = "README.md"
 keywords = ["random", "rng"]
 categories = ["algorithms", "no-std"]
@@ -26,6 +26,9 @@
 [package.metadata.docs.rs]
 all-features = true
 rustdoc-args = ["--cfg", "doc_cfg"]
+
+[package.metadata.playground]
+all-features = true
 [dependencies.getrandom]
 version = "0.2"
 optional = true
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index c383b31..d460757 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,12 +1,12 @@
 [package]
 name = "rand_core"
-version = "0.6.0"
+version = "0.6.2"
 authors = ["The Rand Project Developers", "The Rust Project Developers"]
 license = "MIT OR Apache-2.0"
 readme = "README.md"
 repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_core/"
-homepage = "https://crates.io/crates/rand_core"
+documentation = "https://docs.rs/rand_core"
+homepage = "https://rust-random.github.io/book"
 description = """
 Core random number generator traits and tools for implementation.
 """
@@ -28,3 +28,6 @@
 # RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --all-features --no-deps --open
 all-features = true
 rustdoc-args = ["--cfg", "doc_cfg"]
+
+[package.metadata.playground]
+all-features = true
diff --git a/METADATA b/METADATA
index 37999a5..0e7aa20 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/rand_core/rand_core-0.6.0.crate"
+    value: "https://static.crates.io/crates/rand_core/rand_core-0.6.2.crate"
   }
-  version: "0.6.0"
+  version: "0.6.2"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2020
-    month: 12
-    day: 15
+    year: 2021
+    month: 2
+    day: 17
   }
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
index cd930d1..963506b 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,9 +1,14 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
 {
   "presubmit": [
     {
-      "host": true,
-      "name": "rand_core_host_test_src_lib"
+      "name": "rand_xorshift_device_test_tests_mod"
+    },
+    {
+      "name": "keystore2_test"
+    },
+    {
+      "name": "rand_xorshift_device_test_src_lib"
     },
     {
       "name": "rand_core_device_test_src_lib"
diff --git a/src/le.rs b/src/le.rs
index fa33892..ed42e57 100644
--- a/src/le.rs
+++ b/src/le.rs
@@ -16,7 +16,7 @@
 /// Reads unsigned 32 bit integers from `src` into `dst`.
 #[inline]
 pub fn read_u32_into(src: &[u8], dst: &mut [u32]) {
-    assert!(4 * src.len() >= dst.len());
+    assert!(src.len() >= 4 * dst.len());
     for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(4)) {
         *out = u32::from_le_bytes(chunk.try_into().unwrap());
     }
@@ -25,7 +25,7 @@
 /// Reads unsigned 64 bit integers from `src` into `dst`.
 #[inline]
 pub fn read_u64_into(src: &[u8], dst: &mut [u64]) {
-    assert!(8 * src.len() >= dst.len());
+    assert!(src.len() >= 8 * dst.len());
     for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(8)) {
         *out = u64::from_le_bytes(chunk.try_into().unwrap());
     }
diff --git a/src/lib.rs b/src/lib.rs
index ff553a3..7e847ae 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -300,20 +300,30 @@
     /// considered a value-breaking change.
     fn seed_from_u64(mut state: u64) -> Self {
         // We use PCG32 to generate a u32 sequence, and copy to the seed
-        const MUL: u64 = 6364136223846793005;
-        const INC: u64 = 11634580027462260723;
+        fn pcg32(state: &mut u64) -> [u8; 4] {
+            const MUL: u64 = 6364136223846793005;
+            const INC: u64 = 11634580027462260723;
 
-        let mut seed = Self::Seed::default();
-        for chunk in seed.as_mut().chunks_mut(4) {
             // We advance the state first (to get away from the input value,
             // in case it has low Hamming Weight).
-            state = state.wrapping_mul(MUL).wrapping_add(INC);
+            *state = state.wrapping_mul(MUL).wrapping_add(INC);
+            let state = *state;
 
             // Use PCG output function with to_le to generate x:
             let xorshifted = (((state >> 18) ^ state) >> 27) as u32;
             let rot = (state >> 59) as u32;
             let x = xorshifted.rotate_right(rot);
-            chunk.copy_from_slice(&x.to_le_bytes());
+            x.to_le_bytes()
+        }
+
+        let mut seed = Self::Seed::default();
+        let mut iter = seed.as_mut().chunks_exact_mut(4);
+        for chunk in &mut iter {
+            chunk.copy_from_slice(&pcg32(&mut state));
+        }
+        let rem = iter.into_remainder();
+        if !rem.is_empty() {
+            rem.copy_from_slice(&pcg32(&mut state)[..rem.len()]);
         }
 
         Self::from_seed(seed)