mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-11-09 13:25:29 +08:00
Fix oob in ThrottleKeyHasher::write
This commit is contained in:
parent
38fa0291e2
commit
3275fb4313
1 changed files with 7 additions and 1 deletions
|
|
@ -282,7 +282,13 @@ impl Hasher for ThrottleKeyHasher {
|
|||
}
|
||||
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
self.hash = u64::from_ne_bytes((&bytes[..std::mem::size_of::<u64>()]).try_into().unwrap());
|
||||
debug_assert!(
|
||||
bytes.len() >= std::mem::size_of::<u64>(),
|
||||
"ThrottleKeyHasher: input too short {bytes:?}"
|
||||
);
|
||||
self.hash = bytes
|
||||
.get(0..std::mem::size_of::<u64>())
|
||||
.map_or(0, |b| u64::from_ne_bytes(b.try_into().unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue