h264_cabac: Break infinite loops
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 31 Jan 2013 03:20:24 +0000 (04:20 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 23 Feb 2015 00:06:28 +0000 (00:06 +0000)
This fixes out of array reads and/or infinite loops.

30 is the maximum number of bits that can be read into
coeff_abs below.

CC: libav-stable@libav.org
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Martin Storsjö <martin@martin.st>
libavcodec/h264_cabac.c

index 2ee4bc0..7f86de5 100644 (file)
@@ -1719,7 +1719,7 @@ decode_cabac_residual_internal(H264Context *h, DCTELEM *block,
 \
             if( coeff_abs >= 15 ) { \
                 int j = 0; \
-                while( get_cabac_bypass( CC ) ) { \
+                while (get_cabac_bypass(CC) && j < 30) { \
                     j++; \
                 } \
 \