From: Pierre Joye Date: Sun, 7 May 2006 16:37:40 +0000 (+0000) Subject: - #37346, invalid colormap format X-Git-Tag: php-5.2.0RC1~646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52619b84275afb05d73f9adad0548fcd9c397283;p=php - #37346, invalid colormap format --- diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index 1733a646f3..133753b046 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -44,7 +44,7 @@ static int set_verbose(void) #define LOCALCOLORMAP 0x80 #define BitSet(byte, bit) (((byte) & (bit)) == (bit)) -#define ReadOK(file,buffer,len) (gdGetBuf(buffer, len, file) != 0) +#define ReadOK(file,buffer,len) (gdGetBuf(buffer, len, file) > 0) #define LM_to_uint(a,b) (((b)<<8)|(a)) @@ -184,14 +184,19 @@ gdImageCreateFromGifCtx(gdIOCtxPtr fd) imw = LM_to_uint(buf[4],buf[5]); imh = LM_to_uint(buf[6],buf[7]); - if (!(im = gdImageCreate(imw, imh))) { - return 0; - } + + if (!useGlobalColormap) { + if (ReadColorMap(fd, bitPixel, localColorMap)) { + return 0; + } + } + + if (!(im = gdImageCreate(imw, imh))) { + return 0; + } + im->interlace = BitSet(buf[8], INTERLACE); if (! useGlobalColormap) { - if (ReadColorMap(fd, bitPixel, localColorMap)) { - return 0; - } ReadImage(im, fd, imw, imh, localColorMap, BitSet(buf[8], INTERLACE)); /*1.4//imageCount != imageNumber); */ diff --git a/ext/gd/tests/bug37346.gif b/ext/gd/tests/bug37346.gif new file mode 100644 index 0000000000..76ce1e398e --- /dev/null +++ b/ext/gd/tests/bug37346.gif @@ -0,0 +1,4 @@ +GIF89a +< + +¿´°É, ÎÒ¶¼Ëµ¹ýÂ˲»ÑÏÁË \ No newline at end of file diff --git a/ext/gd/tests/bug37346.phpt b/ext/gd/tests/bug37346.phpt new file mode 100644 index 0000000000..859518e1fd --- /dev/null +++ b/ext/gd/tests/bug37346.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #37346 (gdimagecreatefromgif, bad colormap) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d