diff options
author | Paul B Mahol <onemda@gmail.com> | 2022-03-04 23:25:48 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2022-03-04 23:44:01 +0100 |
commit | 37480b1b85b0405563962b581dc2899b1b4bec59 (patch) | |
tree | 7239e10687679edba04c5863c00dd0365768b19a | |
parent | f497731260d42e920318ca745a8146febb9e055e (diff) | |
download | ffmpeg-37480b1b85b0405563962b581dc2899b1b4bec59.tar.gz |
avcodec/dnxhdenc: fix possible out of bound writes for big w/h
It was caused by integer overflows.
-rw-r--r-- | libavcodec/dnxhdenc.c | 3 | ||||
-rw-r--r-- | libavcodec/dnxhdenc.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index ac92474e56..374fec499b 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1228,6 +1228,9 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) ctx->mb_qscale[mb] = ctx->qscale + 1; ctx->mb_bits[mb] = ctx->mb_rc[rc + ctx->m.mb_num].bits; } + + if (max_bits > ctx->frame_bits) + return AVERROR(EINVAL); } return 0; } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 9e4c869bc4..30ae8c15e3 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -34,7 +34,7 @@ #include "dnxhddata.h" typedef struct RCCMPEntry { - uint16_t mb; + uint32_t mb; int value; } RCCMPEntry; |