From: Christoph M. Becker Date: Tue, 7 May 2019 15:37:35 +0000 (+0200) Subject: Simplify GD null byte injection tests X-Git-Tag: php-7.4.0alpha1~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37d0c7b0e4072889ed05e7d631ee47a6bedf8ef5;p=php Simplify GD null byte injection tests These tests actually check that no file with a name containing a NUL is created by the GD image output functions. This is superfluous, since it is sufficient to check that the function failed, and that an appropriate warning has been raised. We also add missing nullbyte injection tests. --- diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt new file mode 100644 index 0000000000..0b6d1843d3 --- /dev/null +++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing null byte injection in imagebmp +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: imagebmp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d +bool(false) +===DONE=== diff --git a/ext/gd/tests/imagegd2_nullbyte_injection.phpt b/ext/gd/tests/imagegd2_nullbyte_injection.phpt index 4307704ee2..2fc3050421 100644 --- a/ext/gd/tests/imagegd2_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd2_nullbyte_injection.phpt @@ -4,29 +4,11 @@ Testing null byte injection in imagegd2 ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- --EXPECTF-- -imagegd2 TEST - Warning: imagegd2() expects parameter 2 to be a valid path, string given in %s on line %d -bool(false) -bool(false) +NULL diff --git a/ext/gd/tests/imagegd_nullbyte_injection.phpt b/ext/gd/tests/imagegd_nullbyte_injection.phpt index f904bbf174..f5479a0050 100644 --- a/ext/gd/tests/imagegd_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd_nullbyte_injection.phpt @@ -4,30 +4,11 @@ Testing null byte injection in imagegd ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- --EXPECTF-- -imagegd TEST - Warning: imagegd() expects parameter 2 to be a valid path, string given in %s on line %d -bool(false) -bool(false) +NULL diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt index 0f3e5b8bad..c5acdd489e 100644 --- a/ext/gd/tests/imagegif_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt @@ -3,10 +3,6 @@ Testing null byte injection in imagegif --SKIPIF-- --CLEAN-- $tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); @@ -15,23 +11,8 @@ rmdir($tempdir); --FILE-- --EXPECTF-- -imagegif TEST - Warning: imagegif(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d bool(false) -bool(false) diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt index 38eadab4ae..29cb537c3a 100644 --- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt +++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt @@ -15,23 +15,8 @@ rmdir($tempdir); --FILE-- --EXPECTF-- -imagejpeg TEST - Warning: imagejpeg(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d bool(false) -bool(false) diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt index bc9c340397..271d4d5bd3 100644 --- a/ext/gd/tests/imagepng_nullbyte_injection.phpt +++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt @@ -15,23 +15,8 @@ rmdir($tempdir); --FILE-- --EXPECTF-- -imagepng TEST - Warning: imagepng(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d bool(false) -bool(false) diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt index 466584f968..fc5d238f41 100644 --- a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt @@ -15,23 +15,8 @@ rmdir($tempdir); --FILE-- --EXPECTF-- -imagewbmp TEST - Warning: imagewbmp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d bool(false) -bool(false) diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt index 9d46a21140..d778d0a379 100644 --- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt @@ -15,23 +15,8 @@ rmdir($tempdir); --FILE-- --EXPECTF-- -imagewebp TEST - Warning: imagewebp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d bool(false) -bool(false) diff --git a/ext/gd/tests/imagexbm_nullbyte_injection.phpt b/ext/gd/tests/imagexbm_nullbyte_injection.phpt new file mode 100644 index 0000000000..b485315064 --- /dev/null +++ b/ext/gd/tests/imagexbm_nullbyte_injection.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing null byte injection in imagexbm +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: imagexbm() expects parameter 2 to be a valid path, string given in %s on line %d +NULL +===DONE===