Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion crates/fast_rands/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ serde = { workspace = true, default-features = false, features = [
] } # serialization lib
# Document all features of this crate (for `cargo doc`)
document-features = { workspace = true, optional = true }
rand_core = { version = "0.9.5", optional = true }
rand_core = { version = "0.10.1", optional = true }
pyo3 = { workspace = true, optional = true, features = ["serde", "macros"] }

[lints]
Expand Down
40 changes: 22 additions & 18 deletions crates/fast_rands/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use core::{
};

#[cfg(feature = "rand_trait")]
use rand_core::{RngCore, SeedableRng};
use rand_core::{Rng, SeedableRng, TryRng};
use serde::{Deserialize, Serialize};

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -273,7 +273,7 @@ pub trait Rand {
#[cfg(feature = "rand_trait")]
impl<T> Rand for T
where
T: RngCore + SeedableRng + Serialize + for<'de> Deserialize<'de> + Debug,
T: Rng + SeedableRng + Serialize + for<'de> Deserialize<'de> + Debug,
{
fn set_seed(&mut self, seed: u64) {
*self = Self::seed_from_u64(seed);
Expand Down Expand Up @@ -333,17 +333,19 @@ impl_default_new!(Sfc64Rand);
macro_rules! impl_rng_core {
($rand:ty) => {
#[cfg(feature = "rand_trait")]
impl rand_core::RngCore for $rand {
fn next_u32(&mut self) -> u32 {
self.next() as u32
impl TryRng for $rand {
type Error = core::convert::Infallible;

fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
Ok(self.next() as u32)
}

fn next_u64(&mut self) -> u64 {
self.next()
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
Ok(self.next())
}

fn fill_bytes(&mut self, dest: &mut [u8]) {
rand_core::impls::fill_bytes_via_next(self, dest)
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> {
rand_core::utils::fill_bytes_via_next_word(dest, || self.try_next_u64())
}
}
};
Expand Down Expand Up @@ -872,24 +874,26 @@ mod tests {
#[test]
#[cfg(feature = "rand_trait")]
fn test_rand_trait() {
use rand_core::{RngCore, SeedableRng};
use rand_core::{Rng, SeedableRng, TryRng};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
struct CountingRng(u64);

impl RngCore for CountingRng {
fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
impl TryRng for CountingRng {
type Error = core::convert::Infallible;

fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
Ok(self.try_next_u64()? as u32)
}

fn next_u64(&mut self) -> u64 {
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
self.0 += 1;
self.0
Ok(self.0)
}

fn fill_bytes(&mut self, dst: &mut [u8]) {
rand_core::impls::fill_bytes_via_next(self, dst);
fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
rand_core::utils::fill_bytes_via_next_word(dst, || self.try_next_u64())
}
}

Expand All @@ -901,7 +905,7 @@ mod tests {
}
}

// LibAFL's Rand trait is auto-implemented for all SeedableRng + RngCore types.
// LibAFL's Rand trait is auto-implemented for all SeedableRng + Rng types.
assert!(CountingRng(0).coinflip(0.1));
}

Expand Down
2 changes: 1 addition & 1 deletion crates/libafl_bolts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ rustversion = { workspace = true }

[dev-dependencies]
clap = { version = "4.5", features = ["derive", "env"] }
rand = "0.9.0"
rand = "0.10.1"
chrono = "0.4.43"
itertools = "0.14.0"

Expand Down
2 changes: 1 addition & 1 deletion crates/libafl_bolts/examples/simd/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libafl_bolts::simd::{
SimdMinReducer, SimdOrReducer, SimdReducer, VectorType, covmap_is_interesting_naive,
covmap_is_interesting_simd, simplify_map_naive, simplify_map_simd,
};
use rand::{RngCore, rngs::ThreadRng};
use rand::{Rng, rngs::ThreadRng};

fn default_map_size() -> usize {
if std::env::var("CI").is_ok() {
Expand Down
2 changes: 2 additions & 0 deletions crates/libafl_cc/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_imports)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove and fix this.


use core::str;
#[cfg(any(
target_vendor = "apple",
Expand Down
2 changes: 1 addition & 1 deletion crates/libafl_libfuzzer/runtime/Cargo.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ libc = "0.2.159"
log = { version = "0.4.22", features = ["release_max_level_info"] }
mimalloc = { version = "0.1.43", default-features = false }
num-traits = { version = "0.2.19", default-features = true }
rand = "0.8.5"
rand = "0.10.1"
serde = { version = "1.0.228", default-features = true, features = [
"derive",
] } # serialization lib
Expand Down
7 changes: 4 additions & 3 deletions fuzzers/baby/tutorial/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ libafl_targets = { path = "../../../crates/libafl_targets", features = [
serde = { version = "1.0.228", default-features = false, features = [
"alloc",
] } # serialization lib
lain = { version = "0.5.6", features = [
lain = { version = "0.5.7", features = [
"serde_support",
], git = "https://github.com/AFLplusplus/lain.git", rev = "6ac90a35cfff15e314cf33b098f6cac4691c7ab3" } # We're using a lain fork compatible with libafl's rand version
], git = "https://github.com/AFLplusplus/lain.git", rev = "8e2c083670f76acbd7105be2d7f5a58fc38291c0" } # We're using a lain fork compatible with libafl's rand version
# TODO Include it only when building cc
libafl_cc = { path = "../../../crates/libafl_cc" }
libafl_cc = { path = "../../../crates/libafl_cc", default-features = false }
log = { version = "0.4.22", features = ["release_max_level_info"] }

[lib]
name = "tutorial"
Expand Down
Loading