return None if nbloom is zero to avoid potential overflows in malformed gnu hash headers

This commit is contained in:
CT 2022-12-21 13:21:21 +01:00 committed by Christopher Cole
parent 1ed0bdd654
commit 9192854af5

View File

@ -256,8 +256,9 @@ impl<'data, E: EndianParse> GnuHashTable<'data, E> {
symtab: &SymbolTable<'data, E>,
strtab: &StringTable<'data>,
) -> Result<Option<(usize, Symbol)>, ParseError> {
// empty hash tables don't have any entries. This avoids a divde by zero in the modulus calculation
if self.buckets.is_empty() {
// empty hash tables don't have any entries. This avoids a divde by zero in the modulus calculation,
// and also avoids a potential overflow in the bloom filter calculation.
if self.buckets.is_empty() || self.hdr.nbloom == 0 {
return Ok(None);
}