]> granicus.if.org Git - libjpeg-turbo/commitdiff
Check image size when reading targa file
authorFrank Bossen <frank@bossentech.com>
Mon, 29 Dec 2014 17:38:36 +0000 (18:38 +0100)
committerDRC <information@libjpeg-turbo.org>
Fri, 14 Aug 2015 16:42:23 +0000 (11:42 -0500)
Throw an error when image width or height is 0.

Fixes mozilla/mozjpeg#140, closes #7.

rdtarga.c

index afd17c437122c1d7b10ff7eed34d5abe7248ac31..b15ac6472b6354b7018e0e975f3cac7b34b28125 100644 (file)
--- a/rdtarga.c
+++ b/rdtarga.c
@@ -364,7 +364,8 @@ start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
   if (cmaptype > 1 ||           /* cmaptype must be 0 or 1 */
       source->pixel_size < 1 || source->pixel_size > 4 ||
       (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
-      interlace_type != 0)      /* currently don't allow interlaced image */
+      interlace_type != 0 ||      /* currently don't allow interlaced image */
+      width == 0 || height == 0)  /* image width/height must be non-zero */
     ERREXIT(cinfo, JERR_TGA_BADPARMS);
 
   if (subtype > 8) {