]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
deal safely with short inputs in ZSTD_ldm_generateSequences
authorQuentin Carbonneaux <quentin@c9x.me>
Thu, 4 Feb 2021 10:13:41 +0000 (11:13 +0100)
committerQuentin Carbonneaux <quentin@c9x.me>
Thu, 4 Feb 2021 10:15:24 +0000 (11:15 +0100)
The fuzzer CI found this bug.

lib/compress/zstd_ldm.c

index cd6daa0a0c4f7e8fb66dbc37ac15edde121160a2..9292aa4d07ceb98842ee7c767318ccd9ca1973a4 100644 (file)
@@ -328,6 +328,9 @@ static size_t ZSTD_ldm_generateSequences_internal(
     } candidates[LDM_LOOKAHEAD_SPLITS];
     unsigned numSplits;
 
+    if (srcSize < minMatchLength)
+        return iend - anchor;
+
     /* Initialize the rolling hash state with the first minMatchLength bytes */
     ZSTD_ldm_gear_init(&hashState, params);
     {