[SCM] libav/experimental: h264: prevent theoretical infinite loop in SEI parsing

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Aug 10 16:04:07 UTC 2014


The following commit has been merged in the experimental branch:
commit 7ab551f9fd9a63586649a7df8790ddaeac55420f
Author: Vittorio Giovara <vittorio.giovara at gmail.com>
Date:   Wed Jul 30 19:33:36 2014 +0100

    h264: prevent theoretical infinite loop in SEI parsing
    
    Properly address CVE-2011-3946 and parse bitstream as described in the spec.
    
    CC: libav-stable at libav.org
    Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 33230b7..52ff2ff 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -222,14 +222,20 @@ int ff_h264_decode_sei(H264Context *h)
         int size = 0;
         int type = 0;
         int ret  = 0;
+        int last = 0;
 
-        do
-            type += show_bits(&h->gb, 8);
-        while (get_bits(&h->gb, 8) == 255);
+        while (get_bits_left(&h->gb) >= 8 &&
+               (last = get_bits(&h->gb, 8)) == 255) {
+            type += 255;
+        }
+        type += last;
 
-        do
-            size += show_bits(&h->gb, 8);
-        while (get_bits(&h->gb, 8) == 255);
+        last = 0;
+        while (get_bits_left(&h->gb) >= 8 &&
+               (last = get_bits(&h->gb, 8)) == 255) {
+            size += 255;
+        }
+        size += last;
 
         if (size > get_bits_left(&h->gb) / 8) {
             av_log(h->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list