Skip to content

Commit 0aaad46

Browse files
orlitzkynielsdos
authored andcommitted
Fix most external GD 2.3.3 compatibility
* ext/gd/tests/bug45799.phpt: tweak to work with external gd. The expected output from this test contains an extra newline with gd-2.3.3 from the system (Gentoo). Adding a whitespace wildcard takes care of it, and the test still passes with the bundled version of gd. * ext/gd/tests: external gd-2.3.3 compatibility. Support for the legacy "gd" image format was removed from gd-2.3.3 upstream: https://github.com/libgd/libgd/blob/master/CHANGELOG.md#233---2021-09-12 Several tests for the gd extension utilize that format, and naturally fail when gd-2.3.3 from the system is used. This commit skips those tests when the version of gd is at least 2.3.3. * ext/gd/tests/bug73159.phpt: skip with external gd >= 2.3.3 This test uses the imagegd2() function to check that libgd/libgd#289 is fixed. When an external gd without support for the "gd" format is used, no error is thrown, but a nonsense result is printed: this is normal. The corresponding upstream test is disabled in that situation; it's not expected to work. This commit skips the corresponding PHP test under the same circumstances to fix a test failure with external gd >= 2.3.3. * ext/gd/tests/bug73155.phpt: skip with external gd >= 2.3.3 This test uses the imagegd2() function to check that libgd/libgd#309 is fixed. When an external gd without support for the "gd" format is used, no error is thrown, but a nonsense result is printed: this is normal. The corresponding upstream test is disabled in that situation; it's not expected to work. This commit skips the corresponding PHP test under the same circumstances to fix a test failure with external gd >= 2.3.3. * ext/gd/tests/bug73157.phpt: skip with external gd >= 2.3.3 This test ensures that the third (chunk_size) parameter to imagegd2() is respected when a fourth parameter is also given. However, when an external gd without support for the "gd" format is used, the call to imagegd2() does not really work at all. It doesn't fail, but it produces an "image" with a nonsense chunk size. To avoid failures when an external gd >= 2.3.3 is used, we skip the test entirely in that case. * ext/gd/tests/bug77973.phpt: accept lowercase "Invalid" This test fails with an external gd because the test expects "Invalid" where upstream gd says "invalid". This commit tweaks the expected output to accept an arbitrary character in the i/I position. * ext/gd/tests/bug39780_extern.phpt: update for external gd-2.3.3. Since there are no CI runs with external gd, I can only assume that this test has fallen out-of-date due to changes in PHP itself. I've tweaked the expected output (only slightly) so that the test passes with both gd-2.3.2 and gd-2.3.3. * ext/gd/tests/bug66356.phpt: update expected output for external gd. Newer (external) versions of GD start their error messages with lowercase characters, whereas this test is expecting them in uppercase. A single-character wildcard now supports both formats. * ext/gd/tests/imagegd_truecolor.phpt: skip with external gd >= 2.3.3. This test uses the imagegd() function, but the "gd" format has been disabled by default in upstream gd-2.3.3. We still get some kind of image data back from the call to imagegd(), but its "signature", "truecolor", and "size" no longer match the expected values. This commit skips the test when an external gd >= 2.3.3 is used. * ext/gd/tests/createfromwbmp2_extern.phpt: update for external gd-2.3.3. * ext/gd/tests/libgd00086_extern.phpt: update for external gd-2.3.3. Since there are no CI runs with external gd, I can only assume that this test has fallen out-of-date due to changes in PHP itself. I've tweaked the expected output (only slightly) so that the test passes with both gd-2.3.2 and gd-2.3.3. * ext/gd/tests/bug77272.phpt: update expected output for external gd. Newer (external) versions of GD start their error messages with lowercase characters, whereas this test is expecting them in uppercase. A single-character wildcard now supports both formats. * ext/gd/tests/bug77479.phpt: update for newer external gd. This test fails with gd-2.3.3 (at least) due to minor capitalization and whitespace issues. We add some wildcards to account for the difference. Closes GH-11257. Closes GH-11262. Closes GH-11264. Closes GH-11280.
1 parent 849fdca commit 0aaad46

29 files changed

+129
-17
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ PHP NEWS
2222
- FTP:
2323
. Fix context option check for "overwrite". (JonasQuinten)
2424

25+
- GD:
26+
. Fix most of the external libgd test failures. (Michael Orlitzky)
27+
2528
- MBString:
2629
. Fix GH-11300 (license issue: restricted unicode license headers).
2730
(nielsdos)

ext/gd/tests/bug38212-mb.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
require __DIR__ . '/func.inc';

ext/gd/tests/bug38212.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
require __DIR__ . '/func.inc';

ext/gd/tests/bug39780_extern.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ $im = imagecreatefrompng(__DIR__ . '/bug39780.png');
1313
var_dump($im);
1414
?>
1515
--EXPECTF--
16-
gd-png: fatal libpng error: Read Error: truncated data
17-
gd-png error: setjmp returns error condition 2
18-
Warning: imagecreatefrompng(): v%sbug39780.png" is not a valid PNG file in /%s on line %d
16+
Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data%win %s on line %d
17+
18+
Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition %d%win %s on line %d
19+
20+
Warning: imagecreatefrompng(): "%sbug39780.png" is not a valid PNG file in %s on line %d
1921
bool(false)

ext/gd/tests/bug41442.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Bug #41442 (imagegd2() under output control)
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagegd2")) {
812
die("skip GD2 support unavailable");
913
}

ext/gd/tests/bug45799.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ imagepng($img);
99
imagedestroy($img);
1010
?>
1111
--EXPECTF--
12-
Warning: imagepng(): gd-png error: no colors in palette in %s on line %d
12+
Warning: imagepng(): gd-png error: no colors in palette%win %s on line %d

ext/gd/tests/bug66356.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ Array
3838
[height] => 10
3939
)
4040

41-
Warning: imagecrop(): One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
41+
Warning: imagecrop(): %cne parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
4242
in %s on line %d
4343
bool(false)
4444
object(GdImage)#2 (0) {
4545
}
4646
object(GdImage)#2 (0) {
4747
}
4848

49-
Warning: imagecrop(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
49+
Warning: imagecrop(): %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
5050
in %s on line %d
5151
bool(false)

ext/gd/tests/bug71912-mb.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Bug #71912 (libgd: signedness vulnerability)
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED) {
8+
if (version_compare(GD_VERSION, '2.2.0', '<')) {
9+
die("skip test requires GD 2.2.0 or higher");
10+
}
11+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
12+
die("skip test requires GD 2.3.2 or older");
13+
}
14+
}
715
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
816
?>
917
--FILE--

ext/gd/tests/bug71912.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ Bug #71912 (libgd: signedness vulnerability)
44
gd
55
--SKIPIF--
66
<?php
7-
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
8-
die("skip test requires GD 2.2.0 or higher");
7+
if (!GD_BUNDLED) {
8+
if (version_compare(GD_VERSION, '2.2.0', '<')) {
9+
die("skip test requires GD 2.2.0 or higher");
10+
}
11+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
12+
die("skip test requires GD 2.3.2 or older");
13+
}
914
}
1015
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
1116
?>

ext/gd/tests/bug72339.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ gd
55
--SKIPIF--
66
<?php
77
if (!function_exists("imagecreatefromgd2")) print "skip";
8-
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.2', '<')) {
9-
die("skip test requires GD 2.2.2 or higher");
8+
9+
if (!GD_BUNDLED) {
10+
if (version_compare(GD_VERSION, '2.2.2', '<')) {
11+
die("skip test requires GD 2.2.2 or higher");
12+
}
13+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
14+
die("skip test requires GD 2.3.2 or older");
15+
}
1016
}
1117
?>
1218
--FILE--

ext/gd/tests/bug73155.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #73155 (imagegd2() writes wrong chunk sizes on boundaries)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
$im = imagecreate(64, 64);

ext/gd/tests/bug73157.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #73157 (imagegd2() ignores 3rd param if 4 are given)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
$im = imagecreate(8, 8);

ext/gd/tests/bug73159.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #73159 (imagegd2(): unrecognized formats may result in corrupted files)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
$im = imagecreatetruecolor(10, 10);

ext/gd/tests/bug73161.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Bug #73161 (imagecreatefromgd2() may leak memory)
44
We're testing for a memory leak that might not even show up with valgrind.
55
--EXTENSIONS--
66
gd
7+
--SKIPIF--
8+
<?php
9+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
10+
die("skip test requires GD 2.3.2 or older");
11+
}
12+
?>
713
--FILE--
814
<?php
915
$im = imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73161.gd2');

ext/gd/tests/bug73868.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug 73868 (DOS vulnerability in gdImageCreateFromGd2Ctx())
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73868.gd2'));

ext/gd/tests/bug73869.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #73869 (Signed Integer Overflow gd_io.c)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2'));

ext/gd/tests/bug77272.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ $img = imagecreate(2**28, 1);
1616
var_dump(imagescale($img, 1, 1, IMG_TRIANGLE));
1717
?>
1818
--EXPECTF--
19-
Warning: imagescale():%S Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
19+
Warning: imagescale():%S %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
2020
in %s on line %d
2121
bool(false)

ext/gd/tests/bug77479.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ imagecolorallocate($im, 0, 0, 0);
1515
imagewbmp($im, __DIR__ . '/77479.wbmp');
1616
?>
1717
--EXPECTF--
18-
Warning: imagewbmp():%S Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
18+
Warning: imagewbmp():%S %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
1919
in %s on line %d
2020

21-
Warning: imagewbmp(): Could not create WBMP in %s on line %d
21+
Warning: imagewbmp(): Could not create WBMP%win %s on line %d
2222
--CLEAN--
2323
<?php
2424
@unlink(__DIR__ . '/77479.wbmp');

ext/gd/tests/bug77973.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $im = imagecreatefromxbm($filepath);
1515
var_dump($im);
1616
?>
1717
--EXPECTF--
18-
Warning: imagecreatefromxbm(): Invalid XBM in %s on line %d
18+
Warning: imagecreatefromxbm(): %cnvalid XBM in %s on line %d
1919

2020
Warning: imagecreatefromxbm(): "%s" is not a valid XBM file in %s on line %d
2121
bool(false)

ext/gd/tests/crafted_gd2.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Test max colors for a gd image.
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
imagecreatefromgd(__DIR__ . '/crafted.gd2');

ext/gd/tests/createfromgd2.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ imagecreatefromgd2
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
710
if (!function_exists('imagecreatefromgd2')) die("skip gd extension not available\n");
811
?>
912
--FILE--

ext/gd/tests/createfromwbmp2_extern.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ $im = imagecreatefromwbmp($filename);
4343
unlink($filename);
4444
?>
4545
--EXPECTF--
46-
gd warning: Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
46+
Warning: imagecreatefromwbmp(): %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully%win %s on line %d
4747

4848
Warning: imagecreatefromwbmp(): "%s_tmp.wbmp" is not a valid WBMP file in %s on line %d

ext/gd/tests/gif2gd.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ gif --> gd1/gd2 conversion test
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagecreatefromgif")) {
812
die("skip gif read support unavailable");
913
}

ext/gd/tests/imagegd_truecolor.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
imagegd() writes truecolor images without palette conversion
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';

ext/gd/tests/jpg2gd-mb.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ jpeg <--> gd1/gd2 conversion test
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) {
812
die("skip jpeg support unavailable");
913
}

ext/gd/tests/jpg2gd.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ jpeg <--> gd1/gd2 conversion test
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) {
812
die("skip jpeg support unavailable");
913
}

ext/gd/tests/libgd00086_extern.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ $im = imagecreatefrompng(__DIR__ . '/libgd00086.png');
1313
var_dump($im);
1414
?>
1515
--EXPECTF--
16-
gd-png: fatal libpng error: Read Error: truncated data
17-
gd-png error: setjmp returns error condition 1
16+
Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data%win %s on line %d
17+
18+
Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition %d%win %s on line %d
1819

1920
Warning: imagecreatefrompng(): "%slibgd00086.png" is not a valid PNG file in %s on line %d
2021
bool(false)

ext/gd/tests/png2gd.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ png <--> gd1/gd2 conversion test
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) {
812
die("skip png support unavailable");
913
}

ext/gd/tests/xpm2gd.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ xpm --> gd1/gd2 conversion test
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagecreatefromxpm")) {
812
die("skip xpm read support unavailable");
913
}

0 commit comments

Comments
 (0)