From: Quentin Carbonneaux Date: Thu, 4 Feb 2021 10:13:41 +0000 (+0100) Subject: deal safely with short inputs in ZSTD_ldm_generateSequences X-Git-Tag: v1.4.9^2~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=874a590e5ceb9a08beac462ae1e3d3747ccfe17d;p=thirdparty%2Fzstd.git deal safely with short inputs in ZSTD_ldm_generateSequences The fuzzer CI found this bug. --- diff --git a/lib/compress/zstd_ldm.c b/lib/compress/zstd_ldm.c index cd6daa0a0..9292aa4d0 100644 --- a/lib/compress/zstd_ldm.c +++ b/lib/compress/zstd_ldm.c @@ -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); {