cvs: php-src(PHP_5_2) /sapi/cgi cgi_main.c /sapi/cgi/tests 009.phpt
| From: | Ilia Alshanetsky | Date: | Sun, 20 May 2007 15:56:10 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /sapi/cgi cgi_main.c /sapi/cgi/tests 009.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-44392@lists.php.net to get a copy of this message | ||
iliaa Sun May 20 15:56:10 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/sapi/cgi/tests 009.phpt
Modified files:
/php-src/sapi/cgi cgi_main.c
Log:
Fixed a possible crash when PATH_INFO is not provided but the path contains
path info information
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.37&r2=1.267.2.15.2.38&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.37 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.38
--- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.37 Tue May 15 08:17:08 2007
+++ php-src/sapi/cgi/cgi_main.c Sun May 20 15:56:09 2007
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cgi_main.c,v 1.267.2.15.2.37 2007/05/15 08:17:08 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.38 2007/05/20 15:56:09 iliaa Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -825,8 +825,8 @@
* out what SCRIPT_NAME should be
*/
int slen = len - strlen(pt);
- int pilen = strlen(env_path_info);
- char *path_info = env_path_info + pilen - slen;
+ int pilen = env_path_info ? strlen(env_path_info) : 0;
+ char *path_info = env_path_info ? env_path_info + pilen - slen : NULL;
if (orig_path_info != path_info) {
if (orig_path_info) {
@@ -866,10 +866,12 @@
env_script_name = pt + l;
/* PATH_TRANSATED = DOCUMENT_ROOT + PATH_INFO */
- path_translated_len = l + strlen(env_path_info);
+ path_translated_len = l + (env_path_info ? strlen(env_path_info) : 0);
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));
+ if (env_path_info) {
+ 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);
@@ -881,12 +883,14 @@
) {
/* 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);
+ int path_translated_len = ptlen + env_path_info ? strlen(env_path_info) : 0;
char *path_translated = NULL;
path_translated = (char *) emalloc(path_translated_len + 1);
memcpy(path_translated, pt, ptlen);
- memcpy(path_translated + ptlen, env_path_info, path_translated_len - ptlen);
+ if (env_path_info) {
+ 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);
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/009.phpt?view=markup&rev=1.1
Index: php-src/sapi/cgi/tests/009.phpt
+++ php-src/sapi/cgi/tests/009.phpt