[FFmpeg-devel,1/3] avcodec/hevc_cabac: Tighten the limit on k in ff_hevc_cu_qp_delta_abs()

Submitted by Michael Niedermayer on Sept. 9, 2019, 11:36 p.m.

Details

Message ID 20190909233651.30030-1-michael@niedermayer.cc
State Accepted
Commit f63cd1963e36bc70211e072bac7eb3606cf85f14
Headers show

Commit Message

Michael Niedermayer Sept. 9, 2019, 11:36 p.m.
Values larger would fail subsequent tests.

Fixes: signed integer overflow: 5 + 2147483646 cannot be represented in type 'int'
Fixes: 16966/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5695709549953024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/hevc_cabac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Sept. 28, 2019, 5:19 p.m.
On Tue, Sep 10, 2019 at 01:36:49AM +0200, Michael Niedermayer wrote:
> Values larger would fail subsequent tests.
> 
> Fixes: signed integer overflow: 5 + 2147483646 cannot be represented in type 'int'
> Fixes: 16966/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5695709549953024
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hevc_cabac.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index faa36d5459..8abb780dd7 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -642,11 +642,11 @@  int ff_hevc_cu_qp_delta_abs(HEVCContext *s)
     }
     if (prefix_val >= 5) {
         int k = 0;
-        while (k < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc)) {
+        while (k < 7 && get_cabac_bypass(&s->HEVClc->cc)) {
             suffix_val += 1 << k;
             k++;
         }
-        if (k == CABAC_MAX_BIN) {
+        if (k == 7) {
             av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", k);
             return AVERROR_INVALIDDATA;
         }