Fix out-of-bound access of zng_length_codes.

This commit is contained in:
Mika Lindqvist 2023-04-26 02:19:50 +03:00 committed by Hans Kristian Rosbach
parent bf985ade30
commit f346148df0
2 changed files with 3 additions and 0 deletions

View File

@ -99,6 +99,8 @@ Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
if (match_len >= WANT_MIN_MATCH) {
if (UNLIKELY(match_len > s->lookahead))
match_len = s->lookahead;
if (UNLIKELY(match_len > STD_MAX_MATCH))
match_len = STD_MAX_MATCH;
check_match(s, s->strstart, hash_head, match_len);

View File

@ -47,6 +47,7 @@ Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) {
scan < strend);
match_len = STD_MAX_MATCH - (unsigned int)(strend - scan);
match_len = MIN(match_len, s->lookahead);
match_len = MIN(match_len, STD_MAX_MATCH);
}
Assert(scan <= s->window + s->window_size - 1, "wild scan");
}