From: david dot gausmann at measx dot com
Operating system: Windows XP SP3
PHP version: 5.3.0
PHP Bug Type: Program Execution
Bug description: proc_open requires double quotes
Description:
------------
The command, which shall be executed via proc_open, must be put in double
quotes.
This bug was on functions like system, exec, ...
It seems not to be fixed on proc_open.
Reproduce code:
---------------
--- script1.php ---
<?php
//Works fine
echo "1.\r\n";
system('"C:\php\php.exe" "C:\php\script2.php"');
//FAILS!
echo "2.\r\n";
$arPipes = array();
$rProcess = proc_open('"C:\php\php.exe" "C:\php\script2.php"',
array(array('pipe', 'r'), array('pipe', 'w'),
array('pipe', 'w')), $arPipes);
if($rProcess !== false)
{
$nExitCode = -1;
do
{
while(!feof($arPipes[1]))
{
echo fread($arPipes[1], 1024);
flush();
}
$array = proc_get_status($rProcess);
if(!$array)
break;
} while($array['running']);
fclose($arPipes[0]);
fclose($arPipes[1]);
fclose($arPipes[2]);
proc_close($rProcess);
}
//Works fine (double quotes added)
echo "3.\r\n";
$arPipes = array();
$rProcess = proc_open('""C:\php\php.exe" "C:\php\script2.php""',
array(array('pipe', 'r'), array('pipe', 'w'),
array('pipe', 'w')), $arPipes);
if($rProcess !== false)
{
$nExitCode = -1;
do
{
while(!feof($arPipes[1]))
{
echo fread($arPipes[1], 1024);
flush();
}
$array = proc_get_status($rProcess);
if(!$array)
break;
} while($array['running']);
fclose($arPipes[0]);
fclose($arPipes[1]);
fclose($arPipes[2]);
proc_close($rProcess);
}
?>
---script2.php---
<?php
echo "Lorem ipsum\r\n";
exit(0);
?>
Expected result:
----------------
1.
Lorem ipsum
2.
Lorem ipsum
3.
The third call of proc_open should fail, the second one should work.
Actual result:
--------------
1.
Lorem ipsum
2.
3.
Lorem ipsum
The second call of proc_open should fails, but the third one works.
--
Edit bug report at http://bugs.php.net/?id=49139&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49139&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49139&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49139&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49139&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49139&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49139&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49139&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49139&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49139&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49139&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49139&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49139&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49139&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49139&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49139&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49139&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49139&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49139&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49139&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49139&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49139&r=mysqlcfg