aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-01-07 17:51:11 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2022-01-13 23:24:22 +0100
commit171802a1baa46b7bfda8a9ae826b129c67c647a8 (patch)
tree661861fa10fe4f150d5566aabe575dfbd77c227c
parentaf06b9255fafa96e3d269d5d322f5dc736ee7ab9 (diff)
downloadffmpeg-171802a1baa46b7bfda8a9ae826b129c67c647a8.tar.gz
avformat/rawvideodec: check packet size
Fixes: division by zero Fixes: integer overflow Fixes: 43347/clusterfuzz-testcase-minimized-ffmpeg_dem_V210X_fuzzer-5846911637127168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: lance.lmwang@gmail.com Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit c36a5dfc8f68316f93d03081e5a367b04e1cbd3c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/rawvideodec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index 710724c2d1..a7d6a72be7 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -40,6 +40,7 @@ static int rawvideo_read_header(AVFormatContext *ctx)
enum AVPixelFormat pix_fmt;
AVStream *st;
int packet_size;
+ int ret;
st = avformat_new_stream(ctx, NULL);
if (!st)
@@ -57,6 +58,10 @@ static int rawvideo_read_header(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
+ ret = av_image_check_size(s->width, s->height, 0, ctx);
+ if (ret < 0)
+ return ret;
+
st->codecpar->width = s->width;
st->codecpar->height = s->height;
@@ -89,6 +94,8 @@ static int rawvideo_read_header(AVFormatContext *ctx)
if (packet_size < 0)
return packet_size;
}
+ if (packet_size == 0)
+ return AVERROR(EINVAL);
st->codecpar->format = pix_fmt;
ctx->packet_size = packet_size;