OSDN Git Service

avcodec/cook: check that the subpacket sizes fit in block_align
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 30 Oct 2014 15:53:09 +0000 (16:53 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 28 Nov 2014 17:53:11 +0000 (18:53 +0100)
Fixes out of array read
Fixes: asan_heap-oob_fb5c50_19_018.rmvb
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 10e32618acce9c3fc64c061eb7907e8a8d2749ae)

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

index 083d26b..008dee9 100644 (file)
@@ -1217,8 +1217,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
 
         q->num_subpackets++;
         s++;
-        if (s > MAX_SUBPACKETS) {
-            avpriv_request_sample(avctx, "subpackets > %d", MAX_SUBPACKETS);
+        if (s > FFMIN(MAX_SUBPACKETS, avctx->block_align)) {
+            avpriv_request_sample(avctx, "subpackets > %d", FFMIN(MAX_SUBPACKETS, avctx->block_align));
             return AVERROR_PATCHWELCOME;
         }
     }