Skip to content

Commit 59a0f56

Browse files
committed
Updates rand crate to 0.9
Signed-off-by: Simon Davies <[email protected]>
1 parent 203215b commit 59a0f56

File tree

6 files changed

+86
-27
lines changed

6 files changed

+86
-27
lines changed

Cargo.lock

Lines changed: 76 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_host/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ workspace = true
2222

2323
[dependencies]
2424
goblin = { version = "0.9" }
25-
rand = { version = "0.8.5" }
25+
rand = { version = "0.9" }
2626
cfg-if = { version = "1.0.0" }
2727
libc = { version = "0.2.169" }
2828
paste = "1.0"

src/hyperlight_host/examples/otlp_tracing/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
178178
multiuse_sandbox = result.unwrap();
179179
}
180180
let sleep_for = {
181-
let mut rng = rand::thread_rng();
182-
rng.gen_range(500..3000)
181+
let mut rng = rand::rng();
182+
rng.random_range(500..3000)
183183
};
184184
thread::sleep(std::time::Duration::from_millis(sleep_for));
185185
}

src/hyperlight_host/src/hypervisor/surrogate_process_manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ mod tests {
415415
use std::time::{Duration, Instant};
416416

417417
use hyperlight_common::mem::PAGE_SIZE_USIZE;
418-
use rand::{thread_rng, Rng};
418+
use rand::{rng, Rng};
419419
use serial_test::serial;
420420
use windows::Win32::Foundation::{CloseHandle, BOOL, HANDLE, INVALID_HANDLE_VALUE};
421421
use windows::Win32::System::Diagnostics::ToolHelp::{
@@ -439,7 +439,7 @@ mod tests {
439439
for t in 0..NUMBER_OF_SURROGATE_PROCESSES * 2 {
440440
let thread_handle = thread::spawn(move || -> Result<()> {
441441
let surrogate_process_manager_res = get_surrogate_process_manager();
442-
let mut rng = thread_rng();
442+
let mut rng = rng();
443443
let size = PAGE_SIZE_USIZE * 3;
444444
assert!(surrogate_process_manager_res.is_ok());
445445
let surrogate_process_manager = surrogate_process_manager_res.unwrap();
@@ -490,7 +490,7 @@ mod tests {
490490
}
491491

492492
// in real use the process will not get returned immediately
493-
let n: u64 = rng.gen_range(1..16);
493+
let n: u64 = rng.random_range(1..16);
494494
thread::sleep(Duration::from_millis(n));
495495
// dropping the surrogate process, as we do in the line
496496
// below, will return it to the surrogate process manager

src/hyperlight_host/src/mem/layout.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
1716
use std::fmt::Debug;
1817
use std::mem::{offset_of, size_of};
1918

2019
use hyperlight_common::mem::{GuestStackData, HyperlightPEB, RunMode, PAGE_SIZE_USIZE};
2120
use paste::paste;
22-
use rand::rngs::OsRng;
23-
use rand::RngCore;
21+
use rand::{rng, RngCore};
2422
use tracing::{instrument, Span};
2523

2624
use super::memory_region::MemoryRegionType::{
@@ -1100,7 +1098,7 @@ impl SandboxMemoryLayout {
11001098

11011099
// Set up the security cookie seed
11021100
let mut security_cookie_seed = [0u8; 8];
1103-
OsRng.fill_bytes(&mut security_cookie_seed);
1101+
rng().fill_bytes(&mut security_cookie_seed);
11041102
shared_mem.copy_from_slice(&security_cookie_seed, self.peb_security_cookie_seed_offset)?;
11051103

11061104
// Skip guest_dispatch_function_ptr_offset because it is set by the guest

src/hyperlight_host/src/sandbox/uninitialized_evolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ fn hv_init(
102102
let outb_hdl = outb_handler_wrapper(hshm.clone(), host_funcs);
103103
let mem_access_hdl = mem_access_handler_wrapper(hshm.clone());
104104
let seed = {
105-
let mut rng = rand::thread_rng();
106-
rng.gen::<u64>()
105+
let mut rng = rand::rng();
106+
rng.random::<u64>()
107107
};
108108
let peb_addr = {
109109
let peb_u64 = u64::try_from(gshm.layout.peb_address)?;

0 commit comments

Comments
 (0)