Skip to content

Commit

Permalink
[zlib] Fix deflateBound() with chromium_zlib_hash and non-default mem…
Browse files Browse the repository at this point in the history
…Level
  • Loading branch information
fcharlie committed Mar 1, 2024
1 parent 56acd85 commit b5be18e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/archive/zlib/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,12 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
wraplen = 6;
}

/* With Chromium's hashing, s->hash_bits may not correspond to the
memLevel, making the computations below incorrect. Return the
conservative bound. */
if (s->chromium_zlib_hash)
return (fixedlen > storelen ? fixedlen : storelen) + wraplen;

/* if not default parameters, return one of the conservative bounds */
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
Expand Down

0 comments on commit b5be18e

Please sign in to comment.