diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-11-07 21:39:21 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-09 13:53:29 +0200 |
commit | 1e4a9d64d1f361aa2f475f3006524d2526c5a359 (patch) | |
tree | b71698bbe6a27576a6e03e30827f6b79d7afc3b6 | |
parent | a290ea51274a46faa095bc71c32bdc806c45e059 (diff) | |
download | ffmpeg-1e4a9d64d1f361aa2f475f3006524d2526c5a359.tar.gz |
avformat/id3v2: Sanity check tlen before alloc and uncompress
Fixes: Timeout (>20sec -> 65ms)
Fixes: 26896/clusterfuzz-testcase-minimized-ffmpeg_dem_DAUD_fuzzer-5691024049176576
Fixes: 27627/clusterfuzz-testcase-minimized-ffmpeg_dem_AEA_fuzzer-4907019324358656
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d7f87a4b9ef18a9846439b7787874cc11e5940de)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/id3v2.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index bec3300ad6..63df4c21c4 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -1005,6 +1005,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); |