Bug #13813: Character '+' used as argv separator in sapi version
| From: | rxdev at serianet dot com | Date: | Wed, 24 Oct 2001 13:45:13 +0000 |
| Subject: | Bug #13813: Character '+' used as argv separator in sapi version | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-68953@lists.php.net to get a copy of this message | ||
From: rxdev@serianet.com
Operating system: Linux 2.2.19
PHP version: 4.0.6
PHP Bug Type: Scripting Engine problem
Bug description: Character '+' used as argv separator in sapi version
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 bug report at: http://bugs.php.net/?id=13813&edit=1