avcodec/notchlc: Check bytes left before reading
authorMichael Niedermayer <[email protected]>
Mon, 19 Aug 2024 18:37:56 +0000 (20:37 +0200)
committerMichael Niedermayer <[email protected]>
Thu, 27 Feb 2025 16:53:04 +0000 (17:53 +0100)
Fixes: Use of uninitialized value
Fixes: 71230/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-4624502095413248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
(cherry picked from commit b9c7f50c7de9b7d8c533eae173c9b77a6719346c)
Signed-off-by: Michael Niedermayer <[email protected]>
libavcodec/notchlc.c

index 05db9e494301bed68b40460fa38eb1254a7d00a7..558de58fe17705d78d9fc9d388e5dfb028bf4037 100644 (file)
@@ -92,6 +92,9 @@ static int lz4_decompress(AVCodecContext *avctx,
             } while (current == 255);
         }
 
+        if (bytestream2_get_bytes_left(gb) < num_literals)
+            return AVERROR_INVALIDDATA;
+
         if (pos + num_literals < HISTORY_SIZE) {
             bytestream2_get_buffer(gb, history + pos, num_literals);
             pos += num_literals;