summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2021-01-03 21:56:50 -0800
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-01-05 17:08:16 +0100
commitf82f9ea86fa4cdda5038094bda33bc9ba63d3277 (patch)
treea7ef29369fdd26e6ccb1cc8835fcf2b2ba80aea4 /deflate.c
parent692f4d9c483826f015e01ad7b11c4d22f46df936 (diff)
Add check in check_match for invalid match position.
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/deflate.c b/deflate.c
index 0d1d80c..f85bbb4 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;