dmitry          Mon Dec  3 15:08:02 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src    NEWS 
    /php-src/sapi/cgi   cgi_main.c 
  Log:
  Fixed weired behavior in CGI parameter parsing
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1023&r2=1.2027.2.547.2.1024&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1023 php-src/NEWS:1.2027.2.547.2.1024
--- php-src/NEWS:1.2027.2.547.2.1023    Mon Dec  3 14:11:09 2007
+++ php-src/NEWS        Mon Dec  3 15:08:01 2007
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2008, PHP 5.2.6
+- Fixed weired behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson)
+
 - Fixed bug #43482 (array_pad() does not warn on very small pad numbers).
   (Ilia)
 - Fixed bug #43457 (Prepared statement with incorrect parms doens't
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.52&r2=1.267.2.15.2.53&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.52 
php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.53
--- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.52 Thu Nov  1 15:23:14 2007
+++ php-src/sapi/cgi/cgi_main.c Mon Dec  3 15:08:01 2007
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.267.2.15.2.52 2007/11/01 15:23:14 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.53 2007/12/03 15:08:01 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1661,12 +1661,12 @@
                                                }
                                                script_file = 
estrdup(php_optarg);
                                                no_headers = 1;
-                                               /* arguments after the file are 
considered script args */
-                                               SG(request_info).argc = argc - 
(php_optind - 1);
-                                               SG(request_info).argv = 
&argv[php_optind - 1];
                                                break;
 
                                case 'i': /* php info & quit */
+                                               if (script_file) {
+                                                       efree(script_file);
+                                               }
                                                if 
(php_request_startup(TSRMLS_C) == FAILURE) {
                                                        SG(server_context) = 
NULL;
                                                        
php_module_shutdown(TSRMLS_C);
@@ -1687,6 +1687,9 @@
                                                break;
 
                                case 'm': /* list compiled in modules */
+                                       if (script_file) {
+                                               efree(script_file);
+                                       }
                                        php_output_startup();
                                        php_output_activate(TSRMLS_C);
                                        SG(headers_sent) = 1;
@@ -1710,6 +1713,9 @@
                                                break;
 
                                case 'v': /* show php version & quit */
+                                               if (script_file) {
+                                                       efree(script_file);
+                                               }
                                                no_headers = 1;
                                                if 
(php_request_startup(TSRMLS_C) == FAILURE) {
                                                        SG(server_context) = 
NULL;
@@ -1746,6 +1752,18 @@
                                /* override path_translated if -f on command 
line */
                                STR_FREE(SG(request_info).path_translated);
                                SG(request_info).path_translated = script_file;
+                               /* before registering argv to module exchange 
the *new* argv[0] */
+                               /* we can achieve this without allocating more 
memory */
+                               SG(request_info).argc = argc - (php_optind - 1);
+                               SG(request_info).argv = &argv[php_optind - 1];
+                               SG(request_info).argv[0] = script_file;
+                       } else if (argc > php_optind) {
+                               /* file is on command line, but not in -f opt */
+                               STR_FREE(SG(request_info).path_translated);
+                               SG(request_info).path_translated = 
estrdup(argv[php_optind++]);
+                               /* arguments after the file are considered 
script args */
+                               SG(request_info).argc = argc - php_optind;
+                               SG(request_info).argv = &argv[php_optind];
                        }
 
                        if (no_headers) {
@@ -1753,14 +1771,6 @@
                                SG(request_info).no_headers = 1;
                        }
 
-                       if (!SG(request_info).path_translated && argc > 
php_optind) {
-                               /* arguments after the file are considered 
script args */
-                               SG(request_info).argc = argc - php_optind;
-                               SG(request_info).argv = &argv[php_optind];
-                               /* file is on command line, but not in -f opt */
-                               SG(request_info).path_translated = 
estrdup(argv[php_optind++]);
-                       }
-
                        /* all remaining arguments are part of the query string
                           this section of code concatenates all remaining 
arguments
                           into a single string, seperating args with a &

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to