From f82f9ea86fa4cdda5038094bda33bc9ba63d3277 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Sun, 3 Jan 2021 21:56:50 -0800 Subject: [PATCH] Add check in check_match for invalid match position. --- deflate.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; -- 2.47.2