Skip to content

Commit 6e0f486

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix most external GD 2.3.3 compatibility
2 parents 4e3d9b2 + 0aaad46 commit 6e0f486

29 files changed

+129
-17
lines changed

NEWS

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

26+
- GD:
27+
. Fix most of the external libgd test failures. (Michael Orlitzky)
28+
2629
- MBString:
2730
. Fix GH-11300 (license issue: restricted unicode license headers).
2831
(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)