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`]: fd6271fa35/libafl_bolts/src/rands/mod.rs (L373-L376)

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
This commit is contained in:
Railroad6230 2025-01-30 12:26:46 +01:00 committed by GitHub
parent d8df9b4910
commit 5c5f6affcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -371,7 +371,7 @@ impl Rand for Lehmer64Rand {
#[inline] #[inline]
#[expect(clippy::unreadable_literal)] #[expect(clippy::unreadable_literal)]
fn next(&mut self) -> u64 { fn next(&mut self) -> u64 {
self.s *= 0xda942042e4dd58b5; self.s = self.s.wrapping_mul(0xda942042e4dd58b5);
(self.s >> 64) as u64 (self.s >> 64) as u64
} }
} }