1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

avcodec/golomb: Prevent shift by negative number

This happened in get_ue_golomb() if the cached bitstream reader was in
use, because there was no check to handle the case of the read value
not being in the supported range.
For consistency with the uncached bitstream reader and for compliance
with the documentation, every value not in the 0-8190 range is treated as
error although the cached bitstream reader could actually read values in
the range 0..65534 without problems.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt
2020-07-10 15:12:26 +02:00
parent a45935fe05
commit 69636b443c

View File

@@ -66,9 +66,12 @@ static inline int get_ue_golomb(GetBitContext *gb)
return ff_ue_golomb_vlc_code[buf]; return ff_ue_golomb_vlc_code[buf];
} else { } else {
int log = 2 * av_log2(buf) - 31; int log = 2 * av_log2(buf) - 31;
skip_bits_long(gb, 32 - log);
if (log < 7)
return AVERROR_INVALIDDATA;
buf >>= log; buf >>= log;
buf--; buf--;
skip_bits_long(gb, 32 - log);
return buf; return buf;
} }