diff mbox series

[FFmpeg-devel,v2,2/6] avcodec/golomb: Prevent shift by negative number

Message ID 20200714201954.30327-2-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/6] avcodec/golomb: Don't emit error message in get_ue_golomb
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 14, 2020, 8:19 p.m. UTC
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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/golomb.h | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 1f988d74aa..a53486d7cf 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -66,6 +66,8 @@  static inline int get_ue_golomb(GetBitContext *gb)
         return ff_ue_golomb_vlc_code[buf];
     } else {
         int log = 2 * av_log2(buf) - 31;
+        if (log < 0)
+            return AVERROR_INVALIDDATA;
         buf >>= log;
         buf--;
         skip_bits_long(gb, 32 - log);