diff mbox series

[FFmpeg-devel,2/5] avformat/id3v2: Sanity check tlen before alloc and uncompress

Message ID 20201107231710.24816-2-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/5] avformat/tedcaptionsdec: Check for overflow in parse_int() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Nov. 7, 2020, 11:17 p.m. UTC
Fixes: Timeout (>20sec -> 65ms)
Fixes: 26896/clusterfuzz-testcase-minimized-ffmpeg_dem_DAUD_fuzzer-5691024049176576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/id3v2.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index cecd9b9f6d..336a3964de 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -993,6 +993,9 @@  static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata,
 
                     av_log(s, AV_LOG_DEBUG, "Compresssed frame %s tlen=%d dlen=%ld\n", tag, tlen, dlen);
 
+                    if (tlen <= 0)
+                        goto seek;
+
                     av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
                     if (!uncompressed_buffer) {
                         av_log(s, AV_LOG_ERROR, "Failed to alloc %ld bytes\n", dlen);