From: Nathan Moinvaziri Date: Mon, 4 Jan 2021 05:56:50 +0000 (-0800) Subject: Add check in check_match for invalid match position. X-Git-Tag: v2.0.0-RC1~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f82f9ea86fa4cdda5038094bda33bc9ba63d3277;p=thirdparty%2Fzlib-ng.git Add check in check_match for invalid match position. --- diff --git a/deflate.c b/deflate.c index 0d1d80c7..f85bbb46 100644 --- a/deflate.c +++ b/deflate.c @@ -1201,6 +1201,13 @@ void check_match(deflate_state *s, Pos start, Pos match, int length) { fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); z_error("invalid match length"); } + /* check that the match isn't at the beginning of the window and that it isn't at + * the same position as the start string + */ + if (match == 0 || match == start) { + fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); + z_error("invalid match position"); + } /* check that the match is indeed a match */ if (memcmp(s->window + match, s->window + start, length) != EQUAL) { int32_t i = 0;