]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add check in check_match for invalid match position.
authorNathan Moinvaziri <nathan@nathanm.com>
Mon, 4 Jan 2021 05:56:50 +0000 (21:56 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 5 Jan 2021 16:08:16 +0000 (17:08 +0100)
deflate.c

index 0d1d80c7d5555cc84521e07cab857c2502195b43..f85bbb46769fa560618d576726e82c2375572298 100644 (file)
--- 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;