Skip to content

Commit 2e4b6ed

Browse files
paulbissfredemmott
authored andcommitted
[security] [CVE-2018-5711] Sec Bug #75571: Potential infinite loop in gdImageCreateFromGifCtx
CVE-2018-5711
1 parent 5d0afa0 commit 2e4b6ed

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

hphp/runtime/ext/gd/libgd/gd_gif_in.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
258258
if (!im) {
259259
return 0;
260260
}
261-
if (!im->colorsTotal) {
262-
gdImageDestroy(im);
263-
return 0;
264-
}
265261
/* Check for open colors at the end, so
266262
we can reduce colorsTotal and ultimately
267263
BitsPerPixel */
@@ -272,6 +268,10 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
272268
break;
273269
}
274270
}
271+
if (!im->colorsTotal) {
272+
gdImageDestroy(im);
273+
return 0;
274+
}
275275
return im;
276276
}
277277
/* }}} */
@@ -372,7 +372,7 @@ static int
372372
GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP)
373373
{
374374
int i, j, ret;
375-
unsigned char count;
375+
int count;
376376

377377
if (flag) {
378378
scd->curbit = 0;

hphp/test/zend/good/ext/gd/tests/bug75571.gif

Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
var_dump(imagecreatefromgif(__DIR__ . '/bug75571.gif'));
3+
?>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Warning: '%s' is not a valid GIF file in %s on line %d
2+
bool(false)
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
if (!function_exists('imagetypes')) die("skip gd extension not available\n");
3+
?>

0 commit comments

Comments
 (0)