]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cpia: Check input size also against linesizes and EOL
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 19 May 2019 15:42:04 +0000 (17:42 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 20 May 2019 16:10:54 +0000 (18:10 +0200)
Fixes: Timeout (14sec -> 29ms)
Fixes: 14733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5707022445576192
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/cpia.c

index 58833b2f26706d84ada6a9c1754609ca3629caa4..f6d7332606fcee31d88f74db2a42ab97a15b49d6 100644 (file)
@@ -63,7 +63,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
     uint8_t *y, *u, *v, *y_end, *u_end, *v_end;
 
     // Check header
-    if ( avpkt->size < FRAME_HEADER_SIZE
+    if ( avpkt->size < FRAME_HEADER_SIZE + avctx->height * 3
       || header[0] != MAGIC_0 || header[1] != MAGIC_1
       || (header[17] != SUBSAMPLE_420 && header[17] != SUBSAMPLE_422)
       || (header[18] != YUVORDER_YUYV && header[18] != YUVORDER_UYVY)