From 5c5f6affcb6006da0c268f66939ce5b593453449 Mon Sep 17 00:00:00 2001 From: Railroad6230 Date: Thu, 30 Jan 2025 12:26:46 +0100 Subject: [PATCH] Fix Lehmer64 implementation of `next`. (#2912) The implementation of [`Lehmer64Rand::next`] performs a mul on `u128`, which is not checked against overflows. It leads to panic in debug mode. [`Lehmer64Rand`]: https://github.com/AFLplusplus/LibAFL/blob/fd6271fa356f3addda6db33f37db7e42a2c99bbc/libafl_bolts/src/rands/mod.rs#L373-L376 Co-authored-by: Dongjia "toka" Zhang --- libafl_bolts/src/rands/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libafl_bolts/src/rands/mod.rs b/libafl_bolts/src/rands/mod.rs index c55f105b2b..739f4a17b1 100644 --- a/libafl_bolts/src/rands/mod.rs +++ b/libafl_bolts/src/rands/mod.rs @@ -371,7 +371,7 @@ impl Rand for Lehmer64Rand { #[inline] #[expect(clippy::unreadable_literal)] fn next(&mut self) -> u64 { - self.s *= 0xda942042e4dd58b5; + self.s = self.s.wrapping_mul(0xda942042e4dd58b5); (self.s >> 64) as u64 } }