From: Nathan Moinvaziri Date: Thu, 2 Jan 2020 15:59:52 +0000 (-0800) Subject: Removed MAX_DIST2 which is incompatible with zlib when compiled with INFLATE_STRICT... X-Git-Tag: 1.9.9-b1~372 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c4eb71b1d51a1c89ebaff0c16af4d2ae54433e7;p=thirdparty%2Fzlib-ng.git Removed MAX_DIST2 which is incompatible with zlib when compiled with INFLATE_STRICT. It also fixes the check for proper bounds in zng_tr_tally. --- diff --git a/deflate_medium.c b/deflate_medium.c index f694facd..4c975ea5 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -20,8 +20,6 @@ struct match { unsigned int orgstart; }; -#define MAX_DIST2 ((1 << MAX_WBITS) - MIN_LOOKAHEAD) - static int tr_tally_dist(deflate_state *s, int distance, int length) { return zng_tr_tally(s, distance, length); } @@ -162,7 +160,7 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match n = *next; /* step one: try to move the "next" match to the left as much as possible */ - limit = next->strstart > MAX_DIST2 ? next->strstart - MAX_DIST2 : 0; + limit = next->strstart > MAX_DIST(s) ? next->strstart - MAX_DIST(s) : 0; match = s->window + n.match_start - 1; orig = s->window + n.strstart - 1; @@ -249,7 +247,7 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { * At this point we have always match_length < MIN_MATCH */ - if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST2) { + if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). @@ -281,7 +279,7 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ - if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST2) { + if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file).