diff options
author | Anatol Belski <ab@php.net> | 2018-02-16 15:43:54 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-02-16 15:44:43 +0100 |
commit | abf5534113c31b4e171108a8884ffcf368e967dc (patch) | |
tree | 58bdb3f4e6cc8936d0162769b1d46dca22eadf2d /sapi/cgi | |
parent | 535497cb97c678fcf286571a62d57d94f9f35de0 (diff) | |
download | php-git-abf5534113c31b4e171108a8884ffcf368e967dc.tar.gz |
Reduce var scope
Diffstat (limited to 'sapi/cgi')
-rw-r--r-- | sapi/cgi/cgi_main.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index bdf6d34f0b..2682cb674d 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -379,7 +379,6 @@ static void sapi_fcgi_flush(void *server_context) static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) { - char buf[SAPI_CGI_MAX_HEADER_LENGTH]; sapi_header_struct *h; zend_llist_position pos; zend_bool ignore_status = 0; @@ -393,6 +392,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) { int len; zend_bool has_status = 0; + char buf[SAPI_CGI_MAX_HEADER_LENGTH]; if (CGIG(rfc2616_headers) && SG(sapi_headers).http_status_line) { char *s; @@ -790,7 +790,6 @@ static void sapi_cgi_log_message(char *message, int syslog_type_int) */ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const char *doc_root, size_t doc_root_len, int start) { - char *ptr; user_config_cache_entry *new_entry, *entry; time_t request_time = (time_t)sapi_get_request_time(); @@ -806,7 +805,6 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const /* Check whether cache entry has expired and rescan if it is */ if (request_time > entry->expires) { char *real_path = NULL; - size_t real_path_len; char *s1, *s2; size_t s_len; @@ -814,6 +812,7 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const zend_hash_clean(entry->user_config); if (!IS_ABSOLUTE_PATH(path, path_len)) { + size_t real_path_len; real_path = tsrm_realpath(path, NULL); if (real_path == NULL) { return; @@ -842,7 +841,7 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const #else if (strncmp(s1, s2, s_len) == 0) { #endif - ptr = s2 + start; /* start is the point where doc_root ends! */ + char *ptr = s2 + start; /* start is the point where doc_root ends! */ while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { *ptr = 0; php_parse_user_ini_file(path, PG(user_ini_filename), entry->user_config); @@ -866,15 +865,14 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const static int sapi_cgi_activate(void) { - char *path, *doc_root, *server_name; - size_t path_len, doc_root_len, server_name_len; - /* PATH_TRANSLATED should be defined at this stage but better safe than sorry :) */ if (!SG(request_info).path_translated) { return FAILURE; } if (php_ini_has_per_host_config()) { + char *server_name; + /* Activate per-host-system-configuration defined in php.ini and stored into configuration_hash during startup */ if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -885,7 +883,7 @@ static int sapi_cgi_activate(void) } /* SERVER_NAME should also be defined at this stage..but better check it anyway */ if (server_name) { - server_name_len = strlen(server_name); + size_t server_name_len = strlen(server_name); server_name = estrndup(server_name, server_name_len); zend_str_tolower(server_name, server_name_len); php_ini_activate_per_host_config(server_name, server_name_len); @@ -896,6 +894,9 @@ static int sapi_cgi_activate(void) if (php_ini_has_per_dir_config() || (PG(user_ini_filename) && *PG(user_ini_filename)) ) { + char *path; + size_t path_len; + /* Prepare search path */ path_len = strlen(SG(request_info).path_translated); @@ -916,6 +917,8 @@ static int sapi_cgi_activate(void) /* Load and activate user ini files in path starting from DOCUMENT_ROOT */ if (PG(user_ini_filename) && *PG(user_ini_filename)) { + char *doc_root; + if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -925,7 +928,7 @@ static int sapi_cgi_activate(void) } /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */ if (doc_root) { - doc_root_len = strlen(doc_root); + size_t doc_root_len = strlen(doc_root); if (doc_root_len > 0 && IS_SLASH(doc_root[doc_root_len - 1])) { --doc_root_len; } @@ -1589,7 +1592,7 @@ static void add_request_header(char *var, unsigned int var_len, char *val, unsig { zval *return_value = (zval*)arg; char *str = NULL; - char *p; + ALLOCA_FLAG(use_heap) if (var_len > 5 && @@ -1599,6 +1602,8 @@ static void add_request_header(char *var, unsigned int var_len, char *val, unsig var[3] == 'P' && var[4] == '_') { + char *p; + var_len -= 5; p = var + 5; var = str = do_alloca(var_len + 1, use_heap); @@ -1718,12 +1723,12 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ static void add_response_header(sapi_header_struct *h, zval *return_value) /* {{{ */ { - char *s, *p; - size_t len = 0; - ALLOCA_FLAG(use_heap) - if (h->header_len > 0) { - p = strchr(h->header, ':'); + char *s; + size_t len = 0; + ALLOCA_FLAG(use_heap) + + char *p = strchr(h->header, ':'); if (NULL != p) { len = p - h->header; } |