Skip to content

Commit

Permalink
Limit dev_urandom_fallback to Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Jun 13, 2019
1 parent 7b0f9ad commit efb6ede
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ cc = "1.0.26"
[features]
# These features are documented in the top-level module's documentation.
default = ["use_heap", "dev_urandom_fallback"]
dev_urandom_fallback = []
dev_urandom_fallback = ["use_heap"]
internal_benches = []
slow_tests = []
test_logging = []
Expand Down
29 changes: 10 additions & 19 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,6 @@ impl SecureRandom for SystemRandom {

impl sealed::Sealed for SystemRandom {}

#[cfg(all(
feature = "use_heap",
not(any(
target_os = "linux",
target_os = "macos",
target_os = "ios",
target_os = "fuchsia",
windows
))
))]
use self::urandom::fill as fill_impl;

#[cfg(any(
all(target_os = "linux", not(feature = "dev_urandom_fallback")),
windows
Expand Down Expand Up @@ -201,14 +189,17 @@ mod sysrand {
}
}

#[cfg(target_arch = "wasm32")]
mod sysrand {
use crate::error;

pub fn fill(_dest: &mut [u8]) -> Result<(), error::Unspecified> {
unimplemented!()
}
}

// Keep the `cfg` conditions in sync with the conditions in lib.rs.
#[cfg(all(
feature = "use_heap",
any(target_os = "redox", unix),
not(any(target_os = "macos", target_os = "ios")),
not(all(target_os = "linux", not(feature = "dev_urandom_fallback"))),
not(any(target_os = "fuchsia")),
))]
#[cfg(all(target_os = "linux", feature = "dev_urandom_fallback"))]
mod urandom {
use crate::error;

Expand Down

0 comments on commit efb6ede

Please sign in to comment.