[FFmpeg-devel] [PATCH 1/7] avformat/asfdec_o: shrink extradata to the initialized size

Michael Niedermayer michael at niedermayer.cc
Fri Apr 23 20:50:50 EEST 2021


Fixes: OOM
Fixes: 27240/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-5937469859823616

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

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 6cfcd8b088..d08a09c14d 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -600,8 +600,12 @@ static int parse_video_info(AVIOContext *pb, AVStream *st)
         memset(st->codecpar->extradata + st->codecpar->extradata_size , 0,
                AV_INPUT_BUFFER_PADDING_SIZE);
         if ((ret = avio_read(pb, st->codecpar->extradata,
-                             st->codecpar->extradata_size)) < 0)
+                             st->codecpar->extradata_size)) < 0) {
+            st->codecpar->extradata_size = 0;
+            av_freep(&st->codecpar->extradata);
             return ret;
+        }
+        st->codecpar->extradata_size = ret;
     }
     return 0;
 }
-- 
2.17.1



More information about the ffmpeg-devel mailing list