diff options
Diffstat (limited to 'sapi/cgi/cgi_main.c')
-rw-r--r-- | sapi/cgi/cgi_main.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index d1d538345f..8673ec47df 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -162,15 +162,15 @@ static const opt_struct OPTIONS[] = { typedef struct _php_cgi_globals_struct { HashTable user_config_cache; char *redirect_status_env; - zend_bool rfc2616_headers; - zend_bool nph; - zend_bool check_shebang_line; - zend_bool fix_pathinfo; - zend_bool force_redirect; - zend_bool discard_path; - zend_bool fcgi_logging; + bool rfc2616_headers; + bool nph; + bool check_shebang_line; + bool fix_pathinfo; + bool force_redirect; + bool discard_path; + bool fcgi_logging; #ifdef PHP_WIN32 - zend_bool impersonate; + bool impersonate; #endif } php_cgi_globals_struct; @@ -368,7 +368,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) { sapi_header_struct *h; zend_llist_position pos; - zend_bool ignore_status = 0; + bool ignore_status = 0; int response_status = SG(sapi_headers).http_response_code; if (SG(request_info).no_headers == 1) { @@ -378,7 +378,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) if (CGIG(nph) || SG(sapi_headers).http_response_code != 200) { int len; - zend_bool has_status = 0; + bool has_status = 0; char buf[SAPI_CGI_MAX_HEADER_LENGTH]; if (CGIG(rfc2616_headers) && SG(sapi_headers).http_status_line) { @@ -2450,17 +2450,6 @@ parent_loop_end: } } /* end !cgi && !fastcgi */ - /* - we never take stdin if we're (f)cgi, always - rely on the web server giving us the info - we need in the environment. - */ - if (SG(request_info).path_translated || cgi || fastcgi) { - zend_stream_init_filename(&file_handle, SG(request_info).path_translated); - } else { - zend_stream_init_fp(&file_handle, stdin, "Standard input code"); - } - /* request startup only after we've done all we can to * get path_translated */ if (php_request_startup() == FAILURE) { @@ -2520,6 +2509,10 @@ parent_loop_end: free(bindpath); return FAILURE; } + } else { + /* we never take stdin if we're (f)cgi */ + zend_stream_init_fp(&file_handle, stdin, "Standard input code"); + file_handle.primary_script = 1; } if (CGIG(check_shebang_line)) { @@ -2534,9 +2527,9 @@ parent_loop_end: PG(during_request_startup) = 0; exit_status = php_lint_script(&file_handle); if (exit_status == SUCCESS) { - zend_printf("No syntax errors detected in %s\n", file_handle.filename); + zend_printf("No syntax errors detected in %s\n", ZSTR_VAL(file_handle.filename)); } else { - zend_printf("Errors parsing %s\n", file_handle.filename); + zend_printf("Errors parsing %s\n", ZSTR_VAL(file_handle.filename)); } break; case PHP_MODE_STRIP: @@ -2557,22 +2550,22 @@ parent_loop_end: } fastcgi_request_done: - { - if (SG(request_info).path_translated) { - efree(SG(request_info).path_translated); - SG(request_info).path_translated = NULL; - } + zend_destroy_file_handle(&file_handle); - php_request_shutdown((void *) 0); + if (SG(request_info).path_translated) { + efree(SG(request_info).path_translated); + SG(request_info).path_translated = NULL; + } - if (exit_status == 0) { - exit_status = EG(exit_status); - } + php_request_shutdown((void *) 0); - if (free_query_string && SG(request_info).query_string) { - free(SG(request_info).query_string); - SG(request_info).query_string = NULL; - } + if (exit_status == 0) { + exit_status = EG(exit_status); + } + + if (free_query_string && SG(request_info).query_string) { + free(SG(request_info).query_string); + SG(request_info).query_string = NULL; } if (!fastcgi) { |