qdm2: check array index before use, fix out of array accesses
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 30 Nov 2012 22:59:40 +0000 (23:59 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 3 Dec 2012 20:03:14 +0000 (21:03 +0100)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a7ee6281f7ef1c29284e3a4cadfe0f227ffde1ed)

libavcodec/qdm2.c

index 3a77e7f..7f565dd 100644 (file)
@@ -1259,6 +1259,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
     for (i = 0; packet_bytes > 0; i++) {
         int j;
 
+        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
+            SAMPLES_NEEDED_2("too many packet bytes");
+            return;
+        }
+
         q->sub_packet_list_A[i].next = NULL;
 
         if (i > 0) {