[FFmpeg-devel] [PATCH] golomb: check log validity before shifting

Michael Niedermayer michaelni at gmx.at
Sat Jan 12 22:15:12 CET 2013


Fixes invalid right shift in fate-cavs

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/golomb.h |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 0629c78..e3a35e9 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -66,10 +66,14 @@ static inline int get_ue_golomb(GetBitContext *gb){
         return ff_ue_golomb_vlc_code[buf];
     }else{
         log= 2*av_log2(buf) - 31;
-        buf>>= log;
-        buf--;
         LAST_SKIP_BITS(re, gb, 32 - log);
         CLOSE_READER(re, gb);
+        if (log < 0) {
+            av_log(0, AV_LOG_ERROR, "Invalid UE golomb code\n");
+            return AVERROR_INVALIDDATA;
+        }
+        buf>>= log;
+        buf--;
 
         return buf;
     }
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list