Commit e724bd1d authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/utvideodec: Check subsample factors

Fixes: Out of array read
Fixes: heap_poc
Found-by: 's avatarGwanYeong Kim <gy741.kim@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7414d0bd)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 11d04645
......@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
......@@ -474,6 +475,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;
......@@ -538,6 +540,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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment