Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use std::fs;
use std::os::unix::prelude::PermissionsExt;

use rand::Rng;
use rand::SeedableRng;
use rand::rngs::SmallRng;
use tempfile::Builder;
use thiserror::Error;

Expand Down Expand Up @@ -510,7 +512,12 @@ fn dry_exec(tmpdir: &Path, prefix: &str, rand: usize, suffix: &str) -> PathBuf {

// Randomize.
let bytes = &mut buf[prefix.len()..prefix.len() + rand];
rand::rng().fill(bytes);
SmallRng::try_from_os_rng()
.unwrap_or_else(|_| {
//rand::rng panics if getrandom failed
SmallRng::seed_from_u64(bytes.as_ptr() as usize as u64)
})
.fill(bytes);
for byte in bytes {
*byte = match *byte % 62 {
v @ 0..=9 => v + b'0',
Expand Down
Loading