Skip to content

Commit f92fa89

Browse files
committed
gd tweaks
1 parent 48df358 commit f92fa89

11 files changed

+22
-88
lines changed

ext/gd/tests/imagecolorallocatealpha_error1.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
99
--FILE--
1010
<?php
1111
$resource = tmpfile();
12-
1312
imagecolorallocatealpha($resource, 255, 255, 255, 50);
14-
imagecolorallocatealpha('string', 255, 255, 255, 50);
15-
imagecolorallocatealpha(array(), 255, 255, 255, 50);
16-
imagecolorallocatealpha(null, 255, 255, 255, 50);
1713
?>
1814
--EXPECTF--
1915
Warning: imagecolorallocatealpha(): supplied resource is not a valid Image resource in %s on line %d
20-
21-
Warning: imagecolorallocatealpha() expects parameter 1 to be resource, %s given in %s on line %d
22-
23-
Warning: imagecolorallocatealpha() expects parameter 1 to be resource, array given in %s on line %d
24-
25-
Warning: imagecolorallocatealpha() expects parameter 1 to be resource, null given in %s on line %d

ext/gd/tests/imagecolorstotal_error.phpt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test imagecolorstotal() function : error conditions - Pass incorrect number of arguments
2+
Test imagecolorstotal() function : error conditions - Pass invalid resource type
33
--SKIPIF--
44
<?php
55
if(!extension_loaded('gd')) {
@@ -21,13 +21,6 @@ echo "*** Testing imagecolorstotal() : error conditions ***\n";
2121
// Get a resource
2222
$im = fopen(__FILE__, 'r');
2323

24-
echo "\n-- Testing imagecolorstotal() function with Zero arguments --\n";
25-
var_dump( imagecolorstotal() );
26-
27-
echo "\n-- Testing imagecolorstotal() function with more than expected no. of arguments --\n";
28-
$extra_arg = false;
29-
var_dump( imagecolorstotal($im, $extra_arg) );
30-
3124
echo "\n-- Testing imagecolorstotal() function with a invalid resource\n";
3225
var_dump( imagecolorstotal($im) );
3326

@@ -37,16 +30,6 @@ fclose($im);
3730
--EXPECTF--
3831
*** Testing imagecolorstotal() : error conditions ***
3932

40-
-- Testing imagecolorstotal() function with Zero arguments --
41-
42-
Warning: imagecolorstotal() expects exactly 1 parameter, 0 given in %s on line %d
43-
NULL
44-
45-
-- Testing imagecolorstotal() function with more than expected no. of arguments --
46-
47-
Warning: imagecolorstotal() expects exactly 1 parameter, 2 given in %s on line %d
48-
NULL
49-
5033
-- Testing imagecolorstotal() function with a invalid resource
5134

5235
Warning: imagecolorstotal(): supplied resource is not a valid Image resource in %s on line %d

ext/gd/tests/imagecreatetruecolor_error2.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
1111
<?php
1212
$image = imagecreatetruecolor(-1, 30);
1313
$image = imagecreatetruecolor(30, -1);
14-
$image = imagecreatetruecolor(999999999999999999999999999, 30);
15-
$image = imagecreatetruecolor(30, 999999999999999999999999999);
1614
?>
1715
--EXPECTF--
1816
Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d
1917

2018
Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d
21-
22-
Warning: imagecreatetruecolor() expects parameter 1 to be int, float given in %s on line %d
23-
24-
Warning: imagecreatetruecolor() expects parameter 2 to be int, float given in %s on line %d

ext/gd/tests/imagefilter_error1.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ if (!extension_loaded("gd")) die("skip GD not present");
1111
<?php
1212
$image = imagecreatetruecolor(180, 30);
1313

14-
var_dump(imagefilter($image));
14+
try {
15+
var_dump(imagefilter($image));
16+
} catch (TypeError $e) {
17+
echo $e->getMessage(), "\n";
18+
}
1519
?>
16-
--EXPECTF--
17-
Warning: Wrong parameter count for imagefilter() in %s on line %d
18-
NULL
20+
--EXPECT--
21+
Wrong parameter count for imagefilter()

ext/gd/tests/imagegd2_nullbyte_injection.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ $userinput = "1\0"; // from post or get data
2222
$temp = $tempdir. "/test" . $userinput .".tmp";
2323

2424
echo "\nimagegd2 TEST\n";
25-
imagegd2($image, $temp);
25+
try {
26+
imagegd2($image, $temp);
27+
} catch (TypeError $e) {
28+
echo $e->getMessage(), "\n";
29+
}
2630
var_dump(file_exists($tempdir. "/test1"));
2731
var_dump(file_exists($tempdir. "/test1.tmp"));
2832
foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
29-
--EXPECTF--
33+
--EXPECT--
3034
imagegd2 TEST
31-
32-
Warning: imagegd2() expects parameter 2 to be a valid path, string given in %s on line %d
35+
imagegd2() expects parameter 2 to be a valid path, string given
3336
bool(false)
3437
bool(false)

ext/gd/tests/imagegd_nullbyte_injection.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ $userinput = "1\0"; // from post or get data
2222
$temp = $tempdir. "/test" . $userinput .".tmp";
2323

2424
echo "\nimagegd TEST\n";
25-
imagegd($image, $temp);
25+
try {
26+
imagegd($image, $temp);
27+
} catch (TypeError $e) {
28+
echo $e->getMessage(), "\n";
29+
}
2630
var_dump(file_exists($tempdir. "/test1"));
2731
var_dump(file_exists($tempdir. "/test1.tmp"));
2832
foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
29-
--EXPECTF--
33+
--EXPECT--
3034
imagegd TEST
31-
32-
Warning: imagegd() expects parameter 2 to be a valid path, string given in %s on line %d
35+
imagegd() expects parameter 2 to be a valid path, string given
3336
bool(false)
3437
bool(false)

ext/gd/tests/imageistruecolor_error1.phpt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
99
?>
1010
--FILE--
1111
<?php
12-
$image = imagecreatetruecolor(180, 30);
1312
$resource = tmpfile();
14-
15-
imageistruecolor('string');
1613
imageistruecolor($resource);
17-
imageistruecolor(array());
1814
?>
1915
--EXPECTF--
20-
Warning: imageistruecolor() expects parameter 1 to be resource, string given in %s on line %d
21-
2216
Warning: imageistruecolor(): supplied resource is not a valid Image resource in %s on line %d
23-
24-
Warning: imageistruecolor() expects parameter 1 to be resource, array given in %s on line %d

ext/gd/tests/imagesetthickness_error1.phpt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
99
--FILE--
1010
<?php
1111
$resource = tmpfile();
12-
13-
imagesetthickness('string', 5);
14-
imagesetthickness(array(), 5);
1512
imagesetthickness($resource, 5);
1613
?>
1714
--EXPECTF--
18-
Warning: imagesetthickness() expects parameter 1 to be resource, %s given in %s on line %d
19-
20-
Warning: imagesetthickness() expects parameter 1 to be resource, array given in %s on line %d
21-
2215
Warning: imagesetthickness(): supplied resource is not a valid Image resource in %s on line %d

ext/gd/tests/imagetruecolortopalette_error1.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,7 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
1010
--FILE--
1111
<?php
1212
$resource = tmpfile();
13-
1413
imagetruecolortopalette($resource, true, 2);
15-
imagetruecolortopalette('string', true, 2);
16-
imagetruecolortopalette(array(), true, 2);
17-
imagetruecolortopalette(null, true, 2);
1814
?>
1915
--EXPECTF--
2016
Warning: imagetruecolortopalette(): supplied resource is not a valid Image resource in %s on line %d
21-
22-
Warning: imagetruecolortopalette() expects parameter 1 to be resource, %s given in %s on line %d
23-
24-
Warning: imagetruecolortopalette() expects parameter 1 to be resource, array given in %s on line %d
25-
26-
Warning: imagetruecolortopalette() expects parameter 1 to be resource, null given in %s on line %d

ext/gd/tests/imagetruecolortopalette_error3.phpt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
1010
--FILE--
1111
<?php
1212
$image = imagecreatetruecolor(50, 50);
13-
$resource = tmpfile();
14-
15-
imagetruecolortopalette($image, true, 'string');
16-
imagetruecolortopalette($image, true, $resource);
17-
imagetruecolortopalette($image, true, array());
1813
imagetruecolortopalette($image, true, null);
19-
2014
?>
2115
--EXPECTF--
22-
Warning: imagetruecolortopalette() expects parameter 3 to be int, string given in %s on line %d
23-
24-
Warning: imagetruecolortopalette() expects parameter 3 to be int, resource given in %s on line %d
25-
26-
Warning: imagetruecolortopalette() expects parameter 3 to be int, array given in %s on line %d
27-
2816
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s on line %d

0 commit comments

Comments
 (0)