Skip to content
Permalink
Browse files Browse the repository at this point in the history
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 7414d0b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
  • Loading branch information
michaelni committed Jul 9, 2018
1 parent 11d0464 commit e724bd1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libavcodec/utvideodec.c
Expand Up @@ -28,6 +28,7 @@
#include <stdlib.h>

#include "libavutil/intreadwrite.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit e724bd1

Please sign in to comment.