From:             [EMAIL PROTECTED]
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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to