Skip to content

Commit e711325

Browse files
committed
added test for bug #69646
1 parent cd927cc commit e711325

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
Bug #69646 OS command injection vulnerability in escapeshellarg()
3+
--SKIPIF--
4+
<?php
5+
if( substr(PHP_OS, 0, 3) != "WIN" )
6+
die("skip.. Windows only");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
$a = 'a\\';
12+
$b = 'b -c d\\';
13+
var_dump( $a, escapeshellarg($a) );
14+
var_dump( $b, escapeshellarg($b) );
15+
16+
$helper_script = <<<SCRIPT
17+
<?php
18+
19+
print( "--- ARG INFO ---\n" );
20+
var_dump( \$argv );
21+
22+
SCRIPT;
23+
24+
$script = dirname(__FILE__) . DIRECTORY_SEPARATOR . "arginfo.php";
25+
file_put_contents($script, $helper_script);
26+
27+
$cmd = PHP_BINARY . " " . $script . " " . escapeshellarg($a) . " " . escapeshellarg($b);
28+
29+
system($cmd);
30+
31+
unlink($script);
32+
?>
33+
--EXPECTF--
34+
string(2) "a\"
35+
string(5) ""a\\""
36+
string(7) "b -c d\"
37+
string(10) ""b -c d\\""
38+
--- ARG INFO ---
39+
array(3) {
40+
[0]=>
41+
string(%d) "%sarginfo.php"
42+
[1]=>
43+
string(2) "a\"
44+
[2]=>
45+
string(7) "b -c d\"
46+
}
47+

0 commit comments

Comments
 (0)