Commit d98d29a7 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/dirac_vlc: limit res_bits in APPEND_RESIDUE()

Fixes: runtime error: left shift of 1073741838 by 1 places cannot be represented in type 'int32_t' (aka 'int')
Fixes: 3279/clusterfuzz-testcase-minimized-4564805744590848

Suggested-by: <atomnuker>
Reviewed-by: <atomnuker>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4d41db7a
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#define APPEND_RESIDUE(N, M) \ #define APPEND_RESIDUE(N, M) \
N |= M >> (N ## _bits); \ N |= M >> (N ## _bits); \
N ## _bits += (M ## _bits) N ## _bits = (N ## _bits + (M ## _bits)) & 0x3F
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs) int bytes, uint8_t *_dst, int coeffs)
...@@ -56,9 +56,6 @@ int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, ...@@ -56,9 +56,6 @@ int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
if ((c_idx + 1) > coeffs) if ((c_idx + 1) > coeffs)
return c_idx; return c_idx;
if (res_bits >= RSIZE_BITS)
res_bits = res = 0;
/* res_bits is a hint for better branch prediction */ /* res_bits is a hint for better branch prediction */
if (res_bits && l->sign) { if (res_bits && l->sign) {
int32_t coeff = 1; int32_t coeff = 1;
...@@ -99,9 +96,6 @@ int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, ...@@ -99,9 +96,6 @@ int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
if ((c_idx + 1) > coeffs) if ((c_idx + 1) > coeffs)
return c_idx; return c_idx;
if (res_bits >= RSIZE_BITS)
res_bits = res = 0;
if (res_bits && l->sign) { if (res_bits && l->sign) {
int32_t coeff = 1; int32_t coeff = 1;
APPEND_RESIDUE(res, l->preamble); APPEND_RESIDUE(res, l->preamble);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment