avcodec/vvc/dec: Check ff_init_cabac_decoder() for failure

Fixes: signed integer overflow: 1107820800 + 1107820800 cannot be represented in type 'int'
Fixes: left shift of 1091059712 by 6 places cannot be represented in type 'int'
Fixes: 69910/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-5162839971528704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Michael Niedermayer 2024-06-30 19:35:01 +02:00 committed by Paul B Mahol
parent 1b58570366
commit 0749dbf837

View File

@ -476,13 +476,14 @@ static int slices_realloc(VVCFrameContext *fc)
return 0;
}
static void ep_init_cabac_decoder(SliceContext *sc, const int index,
static int ep_init_cabac_decoder(SliceContext *sc, const int index,
const H2645NAL *nal, GetBitContext *gb, const CodedBitstreamUnit *unit)
{
const H266RawSlice *slice = unit->content_ref;
const H266RawSliceHeader *rsh = sc->sh.r;
EntryPoint *ep = sc->eps + index;
int size;
int ret;
if (index < rsh->num_entry_points) {
int skipped = 0;
@ -501,8 +502,11 @@ static void ep_init_cabac_decoder(SliceContext *sc, const int index,
size = get_bits_left(gb) / 8;
}
av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <= gb->buffer_end);
ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb) / 8, size);
ret = ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb) / 8, size);
if (ret < 0)
return ret;
skip_bits(gb, size * 8);
return 0;
}
static int slice_init_entry_points(SliceContext *sc,
@ -538,7 +542,9 @@ static int slice_init_entry_points(SliceContext *sc,
fc->tab.slice_idx[rs] = sc->slice_idx;
}
ep_init_cabac_decoder(sc, i, nal, &gb, unit);
ret = ep_init_cabac_decoder(sc, i, nal, &gb, unit);
if (ret < 0)
return ret;
if (i + 1 < sc->nb_eps)
ctu_addr = sh->entry_point_start_ctu[i];