Bug #13813 Updated: Character '+' used as argv separator in sapi version
| From: | php at Cipri dot com | Date: | Thu, 21 Mar 2002 17:19:42 +0000 |
| Subject: | Bug #13813 Updated: Character '+' used as argv separator in sapi version | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-3068@lists.php.net to get a copy of this message | ||
ID: 13813
Updated by: php@Cipri.com
Reported By: rxdev@serianet.com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Linux 2.2.19
PHP Version: 4.0.6
New Comment:
4.0.6-7 on Linux 2.4.9-31
I had a similar issue, whlie running the following script:
/etc/mgetty+sendfax/fax-fail /var/spool/fax/outgoing/F000052/JOB
after some odd behaviour and debugging, I did a print_r($argv) which
showed this:
Array
(
[0] => /etc/mgetty
[1] => sendfax/fax-fail
[2] => /var/spool/fax/outgoing/F000052/JOB
)
apparantly, it also chops out the + signs from the script name itself.
Previous Comments:
------------------------------------------------------------------------
[2001-10-24 09:45:12] rxdev@serianet.com
The '+' character is used as argv separator in the sapi version of
PHP4. Therefore, executing this script:
<?php
// myscript.php
echo "first=".$argv[1]."\n";
echo "second=".$argv[2]."\n";
?>
Will produce incoherent results if you put a + in one of the
argmuments:
# php -q myscript.php "tomatoes and garlic"
first=tomatoes and garlic
second=
# php -q myscript.php "tomatoes+garlic"
first=tomatoes
second=garlic
The bug is located in PHP source file 'sapi/cgi/cgi_main.c',
line 643 and above,
in function 'int main(int argc, char *argv[])'
...
if (script_file) {
strcpy(s, script_file);
strcat(s, "+");
// ^^^^^^^^ '+' AS SEPARATOR
}
for (i = ap_php_optind, len = 0; i < argc; i++) {
strcat(s, argv[i]);
if (i < (argc - 1)) {
strcat(s, "+");
// ^^^^^^^^ '+' AS SEPARATOR
}
}
...
A quick-and-easy fix might be to use '\n' as separator, or any other
non standard (ascii<32) character.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=13813&edit=1