fuzz: add consume_u64

This commit is contained in:
Bruno Garcia 2025-03-03 15:05:57 -03:00
parent 35e7027a08
commit 66fee1ef87
1 changed files with 22 additions and 0 deletions

View File

@ -9,3 +9,25 @@ pub fn consume_random_bytes<'a>(data: &mut &'a [u8]) -> &'a [u8] {
bytes bytes
} }
#[allow(dead_code)]
pub fn consume_u64(data: &mut &[u8]) -> u64 {
// We need at least 8 bytes to read a u64
if data.len() < 8 {
return 0;
}
let (u64_bytes, rest) = data.split_at(8);
*data = rest;
u64::from_le_bytes([
u64_bytes[0],
u64_bytes[1],
u64_bytes[2],
u64_bytes[3],
u64_bytes[4],
u64_bytes[5],
u64_bytes[6],
u64_bytes[7],
])
}