cvs: php4 /sapi/cgi cgi_main.c
| From: | Andi Gutmans | Date: | Thu, 15 Jun 2000 22:40:52 +0000 |
| Subject: | cvs: php4 /sapi/cgi cgi_main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-296@lists.php.net to get a copy of this message | ||
andi Thu Jun 15 15:40:52 2000 EDT
Modified files:
/php4/sapi/cgi cgi_main.c
Log:
- Try and fix crash with CGI.
- Please check out the comment I wrote in init_request_info(). There was a
- lot of code there which was running for no apparent reason. Should it be
- removed or should it actually run?
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.51 php4/sapi/cgi/cgi_main.c:1.52
--- php4/sapi/cgi/cgi_main.c:1.51 Thu Jun 15 14:34:00 2000
+++ php4/sapi/cgi/cgi_main.c Thu Jun 15 15:40:52 2000
@@ -265,6 +265,10 @@
static void init_request_info(SLS_D)
{
char *content_length = getenv("CONTENT_LENGTH");
+
+#if 0
+/* SG(request_info).path_translated is always set to NULL at the end of this function
+ call so why the hell did this code exist in the first place? Am I missing something? */
char *script_filename;
@@ -299,6 +303,8 @@
}
#endif
+#endif /* 0 */
+
SG(request_info).request_method = getenv("REQUEST_METHOD");
SG(request_info).query_string = getenv("QUERY_STRING");
SG(request_info).request_uri = getenv("PATH_INFO");
@@ -359,7 +365,6 @@
int cgi_started=0;
int behavior=PHP_MODE_STANDARD;
int no_headers=0;
- int free_path_translated=0;
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
char *argv0=NULL;
@@ -498,7 +503,6 @@
}
cgi_started=1;
SG(request_info).path_translated = estrdup(ap_php_optarg);
- free_path_translated=1;
/* break missing intentionally */
case 'q':
no_headers = 1;
@@ -550,8 +554,8 @@
CG(extended_info) = 1;
break;
case 'h':
- case '?':
- no_headers = 1;
+ case '?':
+ no_headers = 1;
php_output_startup();
SG(headers_sent) = 1;
php_cgi_usage(argv[0]);
@@ -561,7 +565,8 @@
case 'd':
define_command_line_ini_entry(ap_php_optarg);
break;
- case 'g': {
+ case 'g':
+ {
char *arg = estrdup(ap_php_optarg);
zend_llist_add_element(&global_vars, &arg);
@@ -612,16 +617,15 @@
SG(request_info).query_string = s;
}
if (!SG(request_info).path_translated && argc > ap_php_optind)
- SG(request_info).path_translated = argv[ap_php_optind];
- }
+ SG(request_info).path_translated = estrdup(argv[ap_php_optind]);
+ } else if (cgi) {
/* If for some reason the CGI interface is not setting the
PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL.
We still call php_fopen_primary_script, because if you set doc_root
or user_dir configuration directives, PATH_INFO is used to construct
the filename as a side effect of php_fopen_primary_script.
*/
- if(cgi) {
- SG(request_info).path_translated = getenv("PATH_TRANSLATED");
+ SG(request_info).path_translated = estrdup(getenv("PATH_TRANSLATED"));
}
if (cgi || SG(request_info).path_translated) {
file_handle.handle.fp = php_fopen_primary_script();
@@ -681,8 +685,9 @@
}
php_header(); /* Make sure headers have been sent */
- if (free_path_translated)
- efree(SG(request_info).path_translated);
+
+ STR_FREE(SG(request_info).path_translated);
+
php_request_shutdown((void *) 0);
php_module_shutdown();
#ifdef ZTS