[FFmpeg-cvslog] gifdec: check that the image dimensions are non-zero

Anton Khirnov git at videolan.org
Sun Jan 12 15:52:50 CET 2014


ffmpeg | branch: release/1.1 | Anton Khirnov <anton at khirnov.net> | Fri Nov 15 10:15:24 2013 +0100| [c5c7e3e6f7cf17943c04bd078f260eaf789afbc9] | committer: Reinhard Tartler

gifdec: check that the image dimensions are non-zero

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 at libav.org

(cherry picked from commit c453723ad7d14abc5e82677eebaa6025fa598f08)
Signed-off-by: Reinhard Tartler <siretart at tauware.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5c7e3e6f7cf17943c04bd078f260eaf789afbc9
---

 libavcodec/gifdec.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 2a962e5..8636780 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -90,8 +90,11 @@ static int gif_read_image(GifState *s)
 
     /* 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);



More information about the ffmpeg-cvslog mailing list