diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2021-01-03 21:56:50 -0800 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2021-01-05 17:08:16 +0100 |
commit | f82f9ea86fa4cdda5038094bda33bc9ba63d3277 (patch) | |
tree | a7ef29369fdd26e6ccb1cc8835fcf2b2ba80aea4 /deflate.c | |
parent | 692f4d9c483826f015e01ad7b11c4d22f46df936 (diff) |
Add check in check_match for invalid match position.
Diffstat (limited to 'deflate.c')
-rw-r--r-- | deflate.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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; |