php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14982 passthru() fails if more than one command line argument is quoted
Submitted: 2002-01-10 18:19 UTC Modified: 2002-08-30 13:51 UTC
From: peter dot linstrom at nist dot gov Assigned:
Status: Closed Package: Performance problem
PHP Version: 4.1.1 OS: Windows NT 4.0/ Windows 2000
Private report: No CVE-ID: None
 [2002-01-10 18:19 UTC] peter dot linstrom at nist dot gov
Problem:
 When the command line passed to passthru contains more than
 one argument that is quoted, the command line is not run.
 For example:

 passthru("\"C:\\Some dir\\prog.exe\" arg"); -- works
 passthru("\"C:\\Some dir\\prog.exe\" \"new arg\""); --fails

Systems tested:
 Windows NT 4.0 and Windows 2000
 Apache 1.3.22 with php4apache.dll
 PHP versions 4.1 and 4.1.1 (problem not present w/ 4.06)
 PHP and Apache are the distributed Windows binaries
 safe_mode is off

Example script:
<html>
<head>
<title>PHP Test Script</title>
</head>
<body>

<h1>PHP Test Script</h1>

<?php
function write_example($command)
{
  // Write a  header.
  echo "\n<h2>Command: ", htmlspecialchars($command), "</h2>\n\n<pre>\n";

  // Run the command.
  passthru($command);

  // Finish up the section.
  echo "\n</pre>\n";

  // Done, return.
  return false;
}

write_example("test.bat");
write_example("\"test.bat\"");
write_example("\"test.bat\" arg");
write_example("\"test.bat\" \"arg\"");
?>

</body>
</html>

Contents of "test.bat" (goes in same dir as script above):
@echo Batch file run OK

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-30 13:51 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 10:01:30 2024 UTC