gifdec: check that the image dimensions are non-zero
authorAnton Khirnov <anton@khirnov.net>
Fri, 15 Nov 2013 09:15:24 +0000 (10:15 +0100)
committerAnton Khirnov <anton@khirnov.net>
Thu, 21 Nov 2013 19:52:42 +0000 (20:52 +0100)
Also add an error message an return a more suitable error code
(INVALIDDATA, not EINVAL);
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org

libavcodec/gifdec.c

index 136d112..b1207ae 100644 (file)
@@ -87,8 +87,11 @@ static int gif_read_image(GifState *s, AVFrame *frame)
 
     /* verify that all the image is inside the screen dimensions */
     if (left + width > s->screen_width ||
-        top + height > s->screen_height)
-        return AVERROR(EINVAL);
+        top + height > s->screen_height ||
+        !width || !height) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid image dimensions.\n");
+        return AVERROR_INVALIDDATA;
+    }
 
     /* build the palette */
     n = (1 << bits_per_pixel);