]> granicus.if.org Git - php/commitdiff
fix flaky gd tests
authorJoe Watkins <krakjoe@php.net>
Wed, 12 Jun 2019 05:52:28 +0000 (07:52 +0200)
committerJoe Watkins <krakjoe@php.net>
Wed, 12 Jun 2019 05:52:28 +0000 (07:52 +0200)
ext/gd/tests/imagegd2_nullbyte_injection.phpt
ext/gd/tests/imagegd_nullbyte_injection.phpt
ext/gd/tests/imagegif_nullbyte_injection.phpt
ext/gd/tests/imagejpeg_nullbyte_injection.phpt
ext/gd/tests/imagepng_nullbyte_injection.phpt
ext/gd/tests/imagewbmp_nullbyte_injection.phpt
ext/gd/tests/imagewebp_nullbyte_injection.phpt

index 2370d5036efd5d5b5291523bad7b5c2d8d58011a..4307704ee209c76186675467d50b8af330f968e4 100644 (file)
@@ -5,16 +5,15 @@ Testing null byte injection in imagegd2
         if(!extension_loaded('gd')){ die('skip gd extension not available'); }
 ?>
 --CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
 foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
 rmdir($tempdir);
 --FILE--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -25,7 +24,6 @@ echo "\nimagegd2 TEST\n";
 imagegd2($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
 --EXPECTF--
 imagegd2 TEST
 
index 25e54fe36c6df641ac7b771d10f14504199b7053..f904bbf17446089b8e73c0362acdb07d600fc7d9 100644 (file)
@@ -5,16 +5,15 @@ Testing null byte injection in imagegd
         if(!extension_loaded('gd')){ die('skip gd extension not available'); }
 ?>
 --CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
 foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
 rmdir($tempdir);
 --FILE--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -25,7 +24,7 @@ echo "\nimagegd TEST\n";
 imagegd($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+?>
 --EXPECTF--
 imagegd TEST
 
index 26cddf3400db7f96cc697533e6c822ff8ca7b632..0f3e5b8bad6a95a6e98edcb680fd72e2e3f37ccc 100644 (file)
@@ -1,9 +1,5 @@
 --TEST--
 Testing null byte injection in imagegif
---CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
-rmdir($tempdir);
 --SKIPIF--
 <?php
 if(!extension_loaded('gd')){ die('skip gd extension not available'); }
@@ -12,13 +8,16 @@ if (!isset($support['GIF Create Support']) || $support['GIF Create Support'] ===
        print 'skip gif support not available';
 }
 ?>
+--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--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -29,7 +28,7 @@ echo "\nimagegif TEST\n";
 imagegif($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+?>
 --EXPECTF--
 imagegif TEST
 
index 3d49584791359e9722d40f5dd71570e616128d66..38eadab4ae21ae44f9ab39b8ae8f1552493fe23f 100644 (file)
@@ -1,9 +1,5 @@
 --TEST--
 Testing null byte injection in imagejpeg
---CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
-rmdir($tempdir);
 --SKIPIF--
 <?php
 if(!extension_loaded('gd')){ die('skip gd extension not available'); }
@@ -12,13 +8,16 @@ if (!isset($support['JPEG Support']) || $support['JPEG Support'] === false) {
        print 'skip jpeg support not available';
 }
 ?>
+--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--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -29,7 +28,7 @@ echo "\nimagejpeg TEST\n";
 imagejpeg($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+?>
 --EXPECTF--
 imagejpeg TEST
 
index 56ba6462e4254db0557e2fb54ab4d3579f7b7890..bc9c3403972ba716e1c7c3921108e94ab3b9e447 100644 (file)
@@ -1,9 +1,5 @@
 --TEST--
 Testing null byte injection in imagepng
---CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
-rmdir($tempdir);
 --SKIPIF--
 <?php
 if(!extension_loaded('gd')){ die('skip gd extension not available'); }
@@ -12,13 +8,16 @@ if (!isset($support['PNG Support']) || $support['PNG Support'] === false) {
        print 'skip png support not available';
 }
 ?>
+--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--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -29,7 +28,7 @@ echo "\nimagepng TEST\n";
 imagepng($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+?>
 --EXPECTF--
 imagepng TEST
 
index 1d3e46044471793e49595a4e0296d222b105cf46..466584f9686492585630b70df5e9e296858b6e11 100644 (file)
@@ -1,9 +1,5 @@
 --TEST--
 Testing null byte injection in imagewbmp
---CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
-rmdir($tempdir);
 --SKIPIF--
 <?php
 if(!extension_loaded('gd')){ die('skip gd extension not available'); }
@@ -12,13 +8,16 @@ if (!isset($support['WBMP Support']) || $support['WBMP Support'] === false) {
        print 'skip wbmp support not available';
 }
 ?>
+--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--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -29,7 +28,7 @@ echo "\nimagewbmp TEST\n";
 imagewbmp($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+?>
 --EXPECTF--
 imagewbmp TEST
 
index 1808e8fb798ce18da890aa70558a9b97adc96050..9d46a2114082ca61a55ec05075a69f7d01ee5565 100644 (file)
@@ -1,9 +1,5 @@
 --TEST--
 Testing null byte injection in imagewebp
---CLEAN--
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
-rmdir($tempdir);
 --SKIPIF--
 <?php
 if(!extension_loaded('gd')){ die('skip gd extension not available'); }
@@ -12,13 +8,16 @@ if (!isset($support['WebP Support']) || $support['WebP Support'] === false) {
        print 'skip webp support not available';
 }
 ?>
+--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--
 <?php
 $image = imagecreate(1,1);// 1px image
 
-
-$tempdir = sys_get_temp_dir(). '/php-gdtest';
-if (!file_exists($tempdir) && !is_dir($tempdir)) {
+$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__));
+if (!is_dir($tempdir)) {
        mkdir ($tempdir, 0777, true);
 }
 
@@ -29,7 +28,6 @@ echo "\nimagewebp TEST\n";
 imagewebp($image, $temp);
 var_dump(file_exists($tempdir. "/test1"));
 var_dump(file_exists($tempdir. "/test1.tmp"));
-foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
 ?>
 --EXPECTF--
 imagewebp TEST