aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-02-26 03:02:48 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-06-18 01:16:03 +0200
commitae49cc73f265a155e5c4b1715570aab3d9741b4d (patch)
treef26ef43d2416b6733fd6a1f14a64ddf59e1c539a
parent30a718c38b62250ef191c8ce040c6c6666ae928c (diff)
downloadffmpeg-ae49cc73f265a155e5c4b1715570aab3d9741b4d.tar.gz
avcodec/utvideodec: Check subsample factors
Fixes: Out of array read Fixes: heap_poc Found-by: GwanYeong Kim <gy741.kim@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 7414d0bda7763f9bd69c26c068e482ab297c1c96) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/utvideodec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index d888cc3cdf..ebd9d55cf2 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -30,6 +30,7 @@
#define UNCHECKED_BITSTREAM_READER 1
#include "libavutil/intreadwrite.h"
+#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
@@ -789,6 +790,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
static av_cold int decode_init(AVCodecContext *avctx)
{
UtvideoContext * const c = avctx->priv_data;
+ int h_shift, v_shift;
c->avctx = avctx;
@@ -886,6 +888,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
+ av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &h_shift, &v_shift);
+ if ((avctx->width & ((1<<h_shift)-1)) ||
+ (avctx->height & ((1<<v_shift)-1))) {
+ avpriv_request_sample(avctx, "Odd dimensions");
+ return AVERROR_PATCHWELCOME;
+ }
+
return 0;
}