diff mbox series

[FFmpeg-devel,2/6] avformat/bethsoftvid: Check image dimensions before use

Message ID 20201017220842.17409-2-michael@niedermayer.cc
State Accepted
Commit 50b29f081e9620dc39727adef707c2c323a8c095
Headers show
Series [FFmpeg-devel,1/6] avformat/asfdec_f: Check for negative ext_len
Related show

Checks

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

Commit Message

Michael Niedermayer Oct. 17, 2020, 10:08 p.m. UTC
Fixes: signed integer overflow: 55255 * 53207 cannot be represented in type 'int'
Fixes: 26387/clusterfuzz-testcase-minimized-ffmpeg_dem_AVS2_fuzzer-5684222226071552

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

Comments

Michael Niedermayer Oct. 23, 2020, 8:03 a.m. UTC | #1
On Sun, Oct 18, 2020 at 12:08:38AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 55255 * 53207 cannot be represented in type 'int'
> Fixes: 26387/clusterfuzz-testcase-minimized-ffmpeg_dem_AVS2_fuzzer-5684222226071552
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/bethsoftvid.c | 6 ++++++
>  1 file changed, 6 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index 47a9a69330..709603daf5 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -28,6 +28,7 @@ 
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -72,6 +73,7 @@  static int vid_read_header(AVFormatContext *s)
 {
     BVID_DemuxContext *vid = s->priv_data;
     AVIOContext *pb = s->pb;
+    int ret;
 
     /* load main header. Contents:
     *    bytes: 'V' 'I' 'D'
@@ -84,6 +86,10 @@  static int vid_read_header(AVFormatContext *s)
     vid->bethsoft_global_delay = avio_rl16(pb);
     avio_rl16(pb);
 
+    ret = av_image_check_size(vid->width, vid->height, 0, s);
+    if (ret < 0)
+        return ret;
+
     // wait until the first packet to create each stream
     vid->video_index = -1;
     vid->audio_index = -1;