diff mbox series

[FFmpeg-devel,2/2] avformat/asfdec_f: Add an additional check for the extradata size

Message ID 20210207205003.29446-2-michael@niedermayer.cc
State Accepted
Commit 2c8cd4490a6ab2742e6ad1ce059b4f4957b39500
Headers show
Series [FFmpeg-devel,1/2] avformat/mov: sanity check STSD entries | expand

Checks

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

Commit Message

Michael Niedermayer Feb. 7, 2021, 8:50 p.m. UTC
Fixes: OOM
Fixes: 30066/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-6182309126602752

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

Comments

Paul B Mahol Feb. 7, 2021, 11:31 p.m. UTC | #1
lgtm
diff mbox series

Patch

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 8e48e457d9..b584f60195 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -516,6 +516,8 @@  static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
         tag1                             = avio_rl32(pb);
         avio_skip(pb, 20);
         if (sizeX > 40) {
+            if (size < sizeX - 40)
+                return AVERROR_INVALIDDATA;
             st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
             st->codecpar->extradata      = av_mallocz(st->codecpar->extradata_size +
                                                    AV_INPUT_BUFFER_PADDING_SIZE);