4xmdemux: Check chunk size
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 16 Apr 2012 12:30:33 +0000 (14:30 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 5 May 2012 22:45:04 +0000 (00:45 +0200)
Fixes over reading the header array

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 474e31c904f766b6989fe614c3fb093e697c847f)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/4xm.c

index 3d9c5ae..90a5fa0 100644 (file)
@@ -129,6 +129,10 @@ static int fourxm_read_header(AVFormatContext *s,
     for (i = 0; i < header_size - 8; i++) {
         fourcc_tag = AV_RL32(&header[i]);
         size = AV_RL32(&header[i + 4]);
+        if (size > header_size - i - 8 && (fourcc_tag == vtrk_TAG || fourcc_tag == strk_TAG)) {
+            av_log(s, AV_LOG_ERROR, "chunk larger than array %d>%d\n", size, header_size - i - 8);
+            return AVERROR_INVALIDDATA;
+        }
 
         if (fourcc_tag == std__TAG) {
             fourxm->fps = av_int2float(AV_RL32(&header[i + 12]));