tony2001                Mon Feb 19 20:01:18 2007 UTC

  Modified files:              
    /php-src/sapi/cgi   README.FastCGI cgi_main.c 
  Log:
  MFB: Eliminate strcat() usage
       Fixed handling of argv[] for GET
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/README.FastCGI?r1=1.5&r2=1.6&diff_format=u
Index: php-src/sapi/cgi/README.FastCGI
diff -u php-src/sapi/cgi/README.FastCGI:1.5 php-src/sapi/cgi/README.FastCGI:1.6
--- php-src/sapi/cgi/README.FastCGI:1.5 Mon Jul 24 12:15:28 2006
+++ php-src/sapi/cgi/README.FastCGI     Mon Feb 19 20:01:17 2007
@@ -69,7 +69,7 @@
 
 Don't load mod_php, by the way. Make sure it is commented out!
 
-    #LoadModule php5_module /usr/lib/apache/2.0/libphp5.so
+    #LoadModule php6_module /usr/lib/apache/2.0/libphp6.so
 
 Now, we'll create a fcgi-bin directory, just like you would do with normal
 CGI scripts. You'll need to create a directory somewhere to store your
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.311&r2=1.312&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.311 php-src/sapi/cgi/cgi_main.c:1.312
--- php-src/sapi/cgi/cgi_main.c:1.311   Mon Feb 19 14:13:35 2007
+++ php-src/sapi/cgi/cgi_main.c Mon Feb 19 20:01:17 2007
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.311 2007/02/19 14:13:35 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.312 2007/02/19 20:01:17 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -836,11 +836,11 @@
                                                        env_script_name = pt + 
l;
 
                                                        /* PATH_TRANSATED = 
DOCUMENT_ROOT + PATH_INFO */
-                                                       path_translated_len = l 
+ strlen(env_path_info) + 2;
-                                                       path_translated = (char 
*) emalloc(path_translated_len);
-                                                       *path_translated = 0;
-                                                       
strncat(path_translated, env_document_root, l);
-                                                       strcat(path_translated, 
env_path_info);
+                                                       path_translated_len = l 
+ strlen(env_path_info);
+                                                       path_translated = (char 
*) emalloc(path_translated_len + 1);
+                                                       memcpy(path_translated, 
env_document_root, l);
+                                                       memcpy(path_translated 
+ l, env_path_info, (path_translated_len - l));
+                                                       
path_translated[path_translated_len] = '\0';
                                                        if 
(orig_path_translated) {
                                                                
_sapi_cgibin_putenv("ORIG_PATH_TRANSLATED", orig_path_translated TSRMLS_CC);
                                                        }
@@ -851,13 +851,13 @@
                                                ) {
                                                        /* PATH_TRANSATED = 
PATH_TRANSATED - SCRIPT_NAME + PATH_INFO */
                                                        int ptlen = strlen(pt) 
- strlen(env_script_name);
-                                                       int path_translated_len 
= ptlen + strlen(env_path_info) + 2;
+                                                       int path_translated_len 
= ptlen + strlen(env_path_info);
                                                        char *path_translated = 
NULL;
 
-                                                       path_translated = (char 
*) emalloc(path_translated_len);
-                                                       *path_translated = 0;
-                                                       
strncat(path_translated, pt, ptlen);
-                                                       strcat(path_translated, 
env_path_info);
+                                                       path_translated = (char 
*) emalloc(path_translated_len + 1);
+                                                       memcpy(path_translated, 
pt, ptlen);
+                                                       memcpy(path_translated 
+ ptlen, env_path_info, path_translated_len - ptlen);
+                                                       
path_translated[path_translated_len] = '\0';
                                                        if 
(orig_path_translated) {
                                                                
_sapi_cgibin_putenv("ORIG_PATH_TRANSLATED", orig_path_translated TSRMLS_CC);
                                                        }
@@ -1559,17 +1559,22 @@
                                   test.php v1=test "v2=hello world!"
                                */
                                if (!SG(request_info).query_string && argc > 
php_optind) {
+                                       int slen = 
strlen(PG(arg_separator).input);
                                        len = 0;
                                        for (i = php_optind; i < argc; i++) {
-                                               len += strlen(argv[i]) + 1;
+                                               if (i < (argc - 1)) {
+                                                       len += strlen(argv[i]) 
+ slen;
+                                               } else {
+                                                       len += strlen(argv[i]);
+                                               }
                                        }
 
-                                       s = malloc(len + 1);
+                                       s = malloc(++len + 1);
                                        *s = '\0';                      /* we 
are pretending it came from the environment  */
-                                       for (i = php_optind, len = 0; i < argc; 
i++) {
-                                               strcat(s, argv[i]);
+                                       for (i = php_optind; i < argc; i++) {
+                                               strlcat(s, argv[i], len);
                                                if (i < (argc - 1)) {
-                                                       strcat(s, 
PG(arg_separator).input);
+                                                       strlcat(s, 
PG(arg_separator).input, len);
                                                }
                                        }
                                        SG(request_info).query_string = s;

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

Reply via email to