aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-05-08 15:17:31 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-05-16 16:00:23 +0200
commite3368b7f8217d2bfa452efbd9a723590e0dcf3f1 (patch)
treea753a3fd37d20465af2d17921b9d68a34c1ef974
parent34a7677f296ee746115e43b437b205cac7f36ee3 (diff)
downloadffmpeg-e3368b7f8217d2bfa452efbd9a723590e0dcf3f1.tar.gz
avcodec/dvbsubdec: check region dimensions
Fixes: 1408/clusterfuzz-testcase-minimized-6529985844084736 Fixes: integer overflow Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 0075d9eced22839fa4f7a6eaa02155803ccae3e6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/dvbsubdec.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index bf3b1a1019..9e48ab4a25 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -24,6 +24,7 @@
#include "bytestream.h"
#include "internal.h"
#include "libavutil/colorspace.h"
+#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#define DVBSUB_PAGE_SEGMENT 0x10
@@ -1242,6 +1243,7 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx,
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
+ int ret;
if (buf_size < 10)
return AVERROR_INVALIDDATA;
@@ -1270,6 +1272,12 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx,
region->height = AV_RB16(buf);
buf += 2;
+ ret = av_image_check_size(region->width, region->height, 0, avctx);
+ if (ret < 0) {
+ region->width= region->height= 0;
+ return ret;
+ }
+
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);