Browse Source

- MFB: #37346, invalid colormap format

migration/RELEASE_1_0_0
Pierre Joye 21 years ago
parent
commit
fc91929f94
  1. 21
      ext/gd/libgd/gd_gif_in.c
  2. 4
      ext/gd/tests/bug37346.gif
  3. 13
      ext/gd/tests/bug37346.phpt

21
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;
}
im->interlace = BitSet(buf[8], INTERLACE);
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); */

4
ext/gd/tests/bug37346.gif

After

Width: 2573  |  Height: 3388  |  Size: 35 B

13
ext/gd/tests/bug37346.phpt

@ -0,0 +1,13 @@
--TEST--
Bug #37346 (gdimagecreatefromgif, bad colormap)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
if (!GD_BUNDLED) die('skip external GD libraries always fail');
?>
--FILE--
<?php
$im = imagecreatefromgif(dirname(__FILE__) . '/bug37346.gif');
?>
--EXPECTF--
Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d
Loading…
Cancel
Save