golomb: check log validity before shifting
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 12 Jan 2013 21:14:25 +0000 (22:14 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 18 Jan 2013 14:41:32 +0000 (15:41 +0100)
Fixes invalid right shift in fate-cavs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/golomb.h

index 0629c78..9f82c74 100644 (file)
@@ -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 (CONFIG_FTRAPV && log < 0) {
+            av_log(0, AV_LOG_ERROR, "Invalid UE golomb code\n");
+            return AVERROR_INVALIDDATA;
+        }
+        buf>>= log;
+        buf--;
 
         return buf;
     }