Skip to content

Commit 296debd

Browse files
committed
avcodec/dnxhddec: Move mb height check out of non hr branch
Fixes: out of array access Fixes: poc.dnxhd Found-by: Bingchang, Liu@VARAS of IIE Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
1 parent 133dafe commit 296debd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: libavcodec/dnxhddec.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,18 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
298298
if (ctx->mb_height > 68 && ff_dnxhd_check_header_prefix_hr(header_prefix)) {
299299
ctx->data_offset = 0x170 + (ctx->mb_height << 2);
300300
} else {
301-
if (ctx->mb_height > 68 ||
302-
(ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
301+
if (ctx->mb_height > 68) {
303302
av_log(ctx->avctx, AV_LOG_ERROR,
304303
"mb height too big: %d\n", ctx->mb_height);
305304
return AVERROR_INVALIDDATA;
306305
}
307306
ctx->data_offset = 0x280;
308307
}
308+
if ((ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
309+
av_log(ctx->avctx, AV_LOG_ERROR,
310+
"mb height too big: %d\n", ctx->mb_height);
311+
return AVERROR_INVALIDDATA;
312+
}
309313

310314
if (buf_size < ctx->data_offset) {
311315
av_log(ctx->avctx, AV_LOG_ERROR,

0 commit comments

Comments
 (0)