Skip to content

Commit 7a2497b

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fix #73968: Premature failing of XBM reading
2 parents 1ff2705 + f67d599 commit 7a2497b

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ PHP NEWS
1616
. Fixed bug #73904 (php-cgi fails to load -c specified php.ini file). (Anatol)
1717
. Fixed bug #72898 (PHP_FCGI_CHILDREN is not included in phpinfo()). (Anatol)
1818

19+
- GD:
20+
. Fixed bug #73968 (Premature failing of XBM reading). (cmb)
21+
1922
- GMP:
2023
. Fixed bug #69993 (test for gmp.h needs to test machine includes).
2124
(Jordan Gigov)

ext/gd/libgd/xbm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ gdImagePtr gdImageCreateFromXbm(FILE * fd)
7777
max_bit = 32768;
7878
}
7979
if (max_bit) {
80-
bytes = (width * height / 8) + 1;
80+
bytes = (width + 7) / 8 * height;
8181
if (!bytes) {
8282
return 0;
8383
}

ext/gd/tests/bug73968.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #73968 (Premature failing of XBM reading)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$im = imagecreatefromxbm(__DIR__ . DIRECTORY_SEPARATOR . 'bug73968.xbm');
10+
var_dump($im);
11+
?>
12+
===DONE===
13+
--EXPECTF--
14+
resource(%d) of type (gd)
15+
===DONE===

ext/gd/tests/bug73968.xbm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define test_width 10
2+
#define test_height 10
3+
static unsigned char test_bits[] = {
4+
0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00,
5+
0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00};

ext/gd/tests/libgd00094-mb.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ $im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094私はガラスを食
1111
var_dump($im);
1212
?>
1313
--EXPECTF--
14-
Warning: imagecreatefromxbm(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
15-
in %slibgd00094-mb.php on line %d
16-
1714
Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.php on line %d
1815
bool(false)
1916

ext/gd/tests/libgd00094.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ $im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094.xbm');
1111
var_dump($im);
1212
?>
1313
--EXPECTF--
14-
Warning: imagecreatefromxbm(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
15-
in %slibgd00094.php on line %d
16-
1714
Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d
1815
bool(false)
1916

0 commit comments

Comments
 (0)