[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
pajoye Mon Jun 22 14:10:40 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: - #48624 .user.ini never gets parsed http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.43r2=1.267.2.15.2.50.2.44diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.43 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.44 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.43Wed Jun 17 19:28:52 2009 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 22 14:10:40 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.43 2009/06/17 19:28:52 pajoye Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.44 2009/06/22 14:10:40 pajoye Exp $ */ #include php.h #include php_globals.h @@ -754,7 +754,7 @@ to find more user.ini, if not we only scan the current path. */ if (strncmp(s1, s2, s_len) == 0) { - ptr = s1 + start; /* start is the point where doc_root ends! */ + 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 TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
pajoye Wed Jun 17 19:22:24 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: - #47318, UMR when trying to activate user config http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.41r2=1.267.2.15.2.50.2.42diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.41 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.42 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.41Tue Jun 9 13:31:39 2009 +++ php-src/sapi/cgi/cgi_main.c Wed Jun 17 19:22:24 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.41 2009/06/09 13:31:39 dsp Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.42 2009/06/17 19:22:24 pajoye Exp $ */ #include php.h #include php_globals.h @@ -706,7 +706,7 @@ /* {{{ php_cgi_ini_activate_user_config */ -static void php_cgi_ini_activate_user_config(char *path, int path_len, int start TSRMLS_DC) +static void php_cgi_ini_activate_user_config(char *path, int path_len, const char *doc_root, int doc_root_len, int start TSRMLS_DC) { char *ptr; user_config_cache_entry *new_entry, *entry; @@ -724,18 +724,49 @@ /* Check whether cache entry has expired and rescan if it is */ if (request_time entry-expires) { + int skip = 0; /* Skip the path as it is not part of the DOCUMENT_ROOT */ + char * real_path; + int real_path_len; + char *s1, *s2; + int s_len; /* Clear the expired config */ zend_hash_clean(entry-user_config); - /* Walk through each directory and apply entries to user_config hash */ - ptr = path + start; /* start is the point where doc_root ends! */ - while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { - *ptr = 0; + if (!IS_ABSOLUTE_PATH(path, path_len)) { + real_path = tsrm_realpath(path, NULL TSRMLS_CC); + real_path_len = strlen(real_path); + path = real_path; + path_len = real_path_len; + } + + if (path_len doc_root_len) { + s1 = (char *) doc_root; + s2 = path; + s_len = doc_root_len; + } else { + s1 = path; + s2 = (char *) doc_root; + s_len = path_len; + } + + /* we have to test if path is part of DOCUMENT_ROOT. + if it is inside the docroot, we scan the tree up to the docroot + to find more user.ini, if not we only scan the current path. + */ + if (strncmp(s1, s2, s_len) == 0) { + ptr = s1 + 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 TSRMLS_CC); + *ptr = '/'; + ptr++; + } + } else { + skip = 1; php_parse_user_ini_file(path, PG(user_ini_filename), entry-user_config TSRMLS_CC); - *ptr = '/'; - ptr++; } + entry-expires = request_time + PG(user_ini_cache_ttl); } @@ -790,10 +821,10 @@ /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */ if (doc_root) { doc_root_len = strlen(doc_root); - if (doc_root[doc_root_len - 1] == '/') { + if (IS_SLASH(doc_root[doc_root_len - 1])) { --doc_root_len; } - php_cgi_ini_activate_user_config(path, path_len, doc_root_len - 1 TSRMLS_CC); + php_cgi_ini_activate_user_config(path, path_len, doc_root, doc_root_len, doc_root_len - 1 TSRMLS_CC); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
pajoye Wed Jun 17 19:28:53 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: - kill unused var http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.42r2=1.267.2.15.2.50.2.43diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.42 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.43 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.42Wed Jun 17 19:22:24 2009 +++ php-src/sapi/cgi/cgi_main.c Wed Jun 17 19:28:52 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.42 2009/06/17 19:22:24 pajoye Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.43 2009/06/17 19:28:52 pajoye Exp $ */ #include php.h #include php_globals.h @@ -724,7 +724,6 @@ /* Check whether cache entry has expired and rescan if it is */ if (request_time entry-expires) { - int skip = 0; /* Skip the path as it is not part of the DOCUMENT_ROOT */ char * real_path; int real_path_len; char *s1, *s2; @@ -763,7 +762,6 @@ ptr++; } } else { - skip = 1; php_parse_user_ini_file(path, PG(user_ini_filename), entry-user_config TSRMLS_CC); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dsp Tue Jun 9 13:31:39 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: Fix bug #47042 (cgi sapi is incorrectly removing the SCRIPT_FILENAME for non apache). The fix was provided by Sriram Natarajan. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.40r2=1.267.2.15.2.50.2.41diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.40 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.41 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.40Thu Jun 4 11:51:43 2009 +++ php-src/sapi/cgi/cgi_main.c Tue Jun 9 13:31:39 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.40 2009/06/04 11:51:43 jani Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.41 2009/06/09 13:31:39 dsp Exp $ */ #include php.h #include php_globals.h @@ -1085,8 +1085,8 @@ } if (env_path_translated != NULL env_redirect_url != NULL - orig_script_filename != NULL script_path_translated != NULL - ) { + env_path_translated != script_path_translated + strcmp(env_path_translated, script_path_translated) != 0) { /* * pretty much apache specific. If we have a redirect_url * then our script_filename and script_name point to the -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
janiThu Jun 4 11:51:43 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH:- Fixed bug #48419 (non-portable STDIN fileno in cgi_main.c) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.39r2=1.267.2.15.2.50.2.40diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.39 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.40 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.39Thu Jun 4 11:47:27 2009 +++ php-src/sapi/cgi/cgi_main.c Thu Jun 4 11:51:43 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.39 2009/06/04 11:47:27 jani Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.40 2009/06/04 11:51:43 jani Exp $ */ #include php.h #include php_globals.h @@ -481,6 +481,9 @@ return SAPI_HEADER_SENT_SUCCESSFULLY; } +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { @@ -493,7 +496,7 @@ fcgi_request *request = (fcgi_request*) SG(server_context); tmp_read_bytes = fcgi_read(request, buffer + read_bytes, count_bytes - read_bytes); } else { - tmp_read_bytes = read(0, buffer + read_bytes, count_bytes - read_bytes); + tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes); } if (tmp_read_bytes = 0) { break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
kalle Tue May 19 16:02:56 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: Fix compiler warnings http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.37r2=1.267.2.15.2.50.2.38diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.37 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.38 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.37Mon Jan 19 18:17:32 2009 +++ php-src/sapi/cgi/cgi_main.c Tue May 19 16:02:55 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.37 2009/01/19 18:17:32 dsp Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.38 2009/05/19 16:02:55 kalle Exp $ */ #include php.h #include php_globals.h @@ -471,7 +471,8 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { - int read_bytes=0, tmp_read_bytes; + uint read_bytes = 0; + int tmp_read_bytes; count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes count_bytes) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dsp Mon Jan 19 18:17:32 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: Fix #47149. Remove check for script_filename = path_translated, as this the actual value that we get from apache. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.36r2=1.267.2.15.2.50.2.37diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.36 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.37 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.36Sun Jan 11 08:35:36 2009 +++ php-src/sapi/cgi/cgi_main.c Mon Jan 19 18:17:32 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.36 2009/01/11 08:35:36 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.37 2009/01/19 18:17:32 dsp Exp $ */ #include php.h #include php_globals.h @@ -1065,8 +1065,7 @@ } if (env_path_translated != NULL env_redirect_url != NULL - orig_script_filename != NULL script_path_translated != NULL - strcmp(orig_script_filename, script_path_translated) != 0) { + orig_script_filename != NULL script_path_translated != NULL) { /* pretty much apache specific. If we have a redirect_url then our script_filename and script_name point to the -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Sun Jan 11 08:35:36 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Disable dl() in CGI and FastCGI modes http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.35r2=1.267.2.15.2.50.2.36diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.35 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.36 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.35Fri Jan 9 22:13:55 2009 +++ php-src/sapi/cgi/cgi_main.c Sun Jan 11 08:35:36 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.35 2009/01/09 22:13:55 dsp Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.36 2009/01/11 08:35:36 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1547,7 +1547,9 @@ #endif cgi_sapi_module.executable_location = argv[0]; - cgi_sapi_module.additional_functions = additional_functions; + if (!cgi !fastcgi !bindpath) { + cgi_sapi_module.additional_functions = additional_functions; + } /* startup after we get the above ini override se we get things right */ if (cgi_sapi_module.startup(cgi_sapi_module) == FAILURE) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dsp Fri Jan 9 22:13:55 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: Fixed bug #47042 (PHP cgi sapi is removing SCRIPT_FILENAME for non apache). http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.34r2=1.267.2.15.2.50.2.35diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.34 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.35 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.34Wed Dec 31 14:27:09 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Jan 9 22:13:55 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.34 2008/12/31 14:27:09 helly Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.35 2009/01/09 22:13:55 dsp Exp $ */ #include php.h #include php_globals.h @@ -1064,7 +1064,9 @@ TRANSLATE_SLASHES(env_document_root); } - if (env_path_translated != NULL env_redirect_url != NULL) { + if (env_path_translated != NULL env_redirect_url != NULL + orig_script_filename != NULL script_path_translated != NULL + strcmp(orig_script_filename, script_path_translated) != 0) { /* pretty much apache specific. If we have a redirect_url then our script_filename and script_name point to the -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Fri Nov 28 11:57:03 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fixed bug #46366 (bad cwd with / as pathinfo) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.31r2=1.267.2.15.2.50.2.32diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.31 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.32 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.31Sat Nov 8 22:56:17 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Nov 28 11:57:02 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.31 2008/11/08 22:56:17 rasmus Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.32 2008/11/28 11:57:02 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1078,6 +1078,9 @@ if (script_path_translated (script_path_translated_len = strlen(script_path_translated)) 0 (script_path_translated[script_path_translated_len-1] == '/' || +#ifdef PHP_WIN32 + script_path_translated[script_path_translated_len-1] == '\\' || +#endif (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL) ) { char *pt = estrndup(script_path_translated, script_path_translated_len); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
rasmus Sat Nov 8 22:56:17 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fix for bug #46525 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.30r2=1.267.2.15.2.50.2.31diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.30 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.31 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.30Tue Oct 21 03:19:28 2008 +++ php-src/sapi/cgi/cgi_main.c Sat Nov 8 22:56:17 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.30 2008/10/21 03:19:28 lbarnaud Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.31 2008/11/08 22:56:17 rasmus Exp $ */ #include php.h #include php_globals.h @@ -454,6 +454,7 @@ } } else if (response_status == 304 h-header_len sizeof(Content-Type:)-1 strncasecmp(h-header, Content-Type:, sizeof(Content-Type:)-1) == 0) { + h = (sapi_header_struct*)zend_llist_get_next_ex(sapi_headers-headers, pos); continue; } else { PHPWRITE_H(h-header, h-header_len); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
iliaa Fri Oct 17 01:31:13 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fixed bug #46319 (PHP sets default Content-Type header for HTTP 304 response code, in cgi sapi) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.28r2=1.267.2.15.2.50.2.29diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.28 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.29 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.28Tue Sep 2 13:22:15 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Oct 17 01:31:12 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.28 2008/09/02 13:22:15 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.29 2008/10/17 01:31:12 iliaa Exp $ */ #include php.h #include php_globals.h @@ -376,6 +376,7 @@ sapi_header_struct *h; zend_llist_position pos; zend_bool ignore_status = 0; + int response_status = SG(sapi_headers).http_response_code; if (SG(request_info).no_headers == 1) { return SAPI_HEADER_SENT_SUCCESSFULLY; @@ -387,7 +388,11 @@ zend_bool has_status = 0; if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { + char *s; len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); + if ((s = strchr(SG(sapi_headers).http_status_line, ' '))) { + response_status = atoi((s + 1)); + } if (len SAPI_CGI_MAX_HEADER_LENGTH) { len = SAPI_CGI_MAX_HEADER_LENGTH; @@ -402,6 +407,7 @@ strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0 ) { len = slprintf(buf, sizeof(buf), Status:%s\r\n, s); + response_status = atoi((s + 1)); } else { h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); while (h) { @@ -446,6 +452,9 @@ PHPWRITE_H(h-header, h-header_len); PHPWRITE_H(\r\n, 2); } + } else if (response_status == 304 h-header_len sizeof(Content-Type:)-1 + strncasecmp(h-header, Content-Type:, sizeof(Content-Type:)-1) == 0) { + continue; } else { PHPWRITE_H(h-header, h-header_len); PHPWRITE_H(\r\n, 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c /sapi/cgi/tests 010.phpt
dmitry Tue Sep 2 13:22:16 2008 UTC Added files: (Branch: PHP_5_3) /php-src/sapi/cgi/tests 010.phpt Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #45860 (header() function fails to correctly replace all Status lines) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.27r2=1.267.2.15.2.50.2.28diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.27 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.28 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.27Tue Aug 26 15:37:01 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Sep 2 13:22:15 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.27 2008/08/26 15:37:01 rasmus Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.28 2008/09/02 13:22:15 dmitry Exp $ */ #include php.h #include php_globals.h @@ -375,6 +375,7 @@ char buf[SAPI_CGI_MAX_HEADER_LENGTH]; sapi_header_struct *h; zend_llist_position pos; + zend_bool ignore_status = 0; if (SG(request_info).no_headers == 1) { return SAPI_HEADER_SENT_SUCCESSFULLY; @@ -430,6 +431,7 @@ } if (!has_status) { PHPWRITE_H(buf, len); + ignore_status = 1; } } @@ -437,8 +439,17 @@ while (h) { /* prevent CRLFCRLF */ if (h-header_len) { - PHPWRITE_H(h-header, h-header_len); - PHPWRITE_H(\r\n, 2); + if (h-header_len sizeof(Status:)-1 + strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0) { + if (!ignore_status) { + ignore_status = 1; + PHPWRITE_H(h-header, h-header_len); + PHPWRITE_H(\r\n, 2); + } + } else { + PHPWRITE_H(h-header, h-header_len); + PHPWRITE_H(\r\n, 2); + } } h = (sapi_header_struct*)zend_llist_get_next_ex(sapi_headers-headers, pos); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/010.phpt?view=markuprev=1.1 Index: php-src/sapi/cgi/tests/010.phpt +++ php-src/sapi/cgi/tests/010.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c /sapi/cgi/tests 010.phpt
On Tue, Sep 2, 2008 at 2:22 PM, Dmitry Stogov [EMAIL PROTECTED] wrote: dmitry Tue Sep 2 13:22:16 2008 UTC Added files: (Branch: PHP_5_3) /php-src/sapi/cgi/tests 010.phpt Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #45860 (header() function fails to correctly replace all Status lines) Hello, I was checking the same issue a bit myself and noticed one edge case where this fix might be slightly unintuitive: # cat test.php ?php header(HTTP/1.1 404 Not found); header(Status: 403 Forbidden); ? # /opt/php/branches/5_3/bin/php-cgi test.php Status: 404 Not found X-Powered-By: PHP/5.3.0alpha3-dev Content-type: text/html # cat test2.php ?php header(HTTP/1.1 404 Not Found); header(HTTP/1.1 403 Forbidden); ? # /opt/php/branches/5_3/bin/php-cgi test2.php Status: 403 Forbidden X-Powered-By: PHP/5.3.0alpha3-dev Content-type: text/html The question in here is: Should explicit Status: header override the status code and message given in HTTP/ header? -- Mikko Koppanen -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
rasmus Tue Aug 26 15:37:01 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Remove stray folding tag here http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.26r2=1.267.2.15.2.50.2.27diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.26 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.27 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.26Tue Aug 26 09:56:08 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 15:37:01 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.26 2008/08/26 09:56:08 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.27 2008/08/26 15:37:01 rasmus Exp $ */ #include php.h #include php_globals.h @@ -175,7 +175,7 @@ HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) /* {{{ */ +static void user_config_cache_entry_dtor(user_config_cache_entry *entry) { zend_hash_destroy(entry-user_config); free(entry-user_config); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Mon Aug 18 10:49:35 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fix for bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.24r2=1.267.2.15.2.50.2.25diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.24 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.24Fri Aug 15 07:30:50 2008 +++ php-src/sapi/cgi/cgi_main.c Mon Aug 18 10:49:35 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.24 2008/08/15 07:30:50 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.25 2008/08/18 10:49:35 dmitry Exp $ */ #include php.h #include php_globals.h @@ -586,10 +586,10 @@ /* turn off magic_quotes while importing environment variables */ PG(magic_quotes_gpc) = 0; - for (zend_hash_internal_pointer_reset_ex(request-env, pos); -zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING -zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; -zend_hash_move_forward_ex(request-env, pos) + for (zend_hash_internal_pointer_reset_ex(request-env, pos); +zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING +zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; +zend_hash_move_forward_ex(request-env, pos) ) { unsigned int new_val_len; http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.4r2=1.4.2.13.2.28.2.5diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.4 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.4Tue Jul 15 13:11:19 2008 +++ php-src/sapi/cgi/fastcgi.c Mon Aug 18 10:49:35 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.4 2008/07/15 13:11:19 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.5 2008/08/18 10:49:35 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -641,7 +641,7 @@ memcpy(tmp, p, name_len); tmp[name_len] = 0; s = estrndup((char*)p + name_len, val_len); - zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); + zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); p += name_len + val_len; } if (tmp != buf tmp != NULL) { @@ -665,7 +665,8 @@ req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; - zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); + ALLOC_HASHTABLE(req-env); + zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); if (safe_read(req, hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version FCGI_VERSION_1) { @@ -702,15 +703,15 @@ switch fcgi_begin_request*)buf)-roleB1 8) + ((fcgi_begin_request*)buf)-roleB0) { case FCGI_RESPONDER: val = estrdup(RESPONDER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_AUTHORIZER: val = estrdup(AUTHORIZER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_FILTER: val = estrdup(FILTER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; default: return 0; @@ -762,7 +763,7 @@ } for (j = 0; j sizeof(fcgi_mgmt_vars)/sizeof(fcgi_mgmt_vars[0]); j++) { - if (zend_hash_exists(req-env, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].name_len+1) == 0) { + if
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
No MFH to PHP_5_2 or isn't this a bug fix..? --Jani Dmitry Stogov wrote: dmitry Mon Aug 18 10:49:35 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fix for bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.24r2=1.267.2.15.2.50.2.25diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.24 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.24Fri Aug 15 07:30:50 2008 +++ php-src/sapi/cgi/cgi_main.c Mon Aug 18 10:49:35 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.24 2008/08/15 07:30:50 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.25 2008/08/18 10:49:35 dmitry Exp $ */ #include php.h #include php_globals.h @@ -586,10 +586,10 @@ /* turn off magic_quotes while importing environment variables */ PG(magic_quotes_gpc) = 0; - for (zend_hash_internal_pointer_reset_ex(request-env, pos); -zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING -zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; -zend_hash_move_forward_ex(request-env, pos) + for (zend_hash_internal_pointer_reset_ex(request-env, pos); +zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING +zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; +zend_hash_move_forward_ex(request-env, pos) ) { unsigned int new_val_len; http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.4r2=1.4.2.13.2.28.2.5diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.4 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.4Tue Jul 15 13:11:19 2008 +++ php-src/sapi/cgi/fastcgi.c Mon Aug 18 10:49:35 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.4 2008/07/15 13:11:19 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.5 2008/08/18 10:49:35 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -641,7 +641,7 @@ memcpy(tmp, p, name_len); tmp[name_len] = 0; s = estrndup((char*)p + name_len, val_len); - zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); + zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); p += name_len + val_len; } if (tmp != buf tmp != NULL) { @@ -665,7 +665,8 @@ req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; - zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); + ALLOC_HASHTABLE(req-env); + zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); if (safe_read(req, hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version FCGI_VERSION_1) { @@ -702,15 +703,15 @@ switch fcgi_begin_request*)buf)-roleB1 8) + ((fcgi_begin_request*)buf)-roleB0) { case FCGI_RESPONDER: val = estrdup(RESPONDER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_AUTHORIZER: val = estrdup(AUTHORIZER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_FILTER: val = estrdup(FILTER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; default: return 0; @@ -762,7 +763,7 @@ } for (j = 0; j sizeof(fcgi_mgmt_vars)/sizeof(fcgi_mgmt_vars[0]); j++) { - if (zend_hash_exists(req-env, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].name_len+1) == 0) {
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Fri Aug 15 07:30:50 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fixed double call to MSHUTDOWN in case of `php-cgi -m` http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.23r2=1.267.2.15.2.50.2.24diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.23 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.24 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.23Wed Aug 13 00:53:28 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Aug 15 07:30:50 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.23 2008/08/13 00:53:28 jani Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.24 2008/08/15 07:30:50 dmitry Exp $ */ #include php.h #include php_globals.h @@ -247,6 +247,7 @@ zend_llist sorted_exts; zend_llist_copy(sorted_exts, zend_extensions); + sorted_exts.dtor = NULL; zend_llist_sort(sorted_exts, extension_name_cmp TSRMLS_CC); zend_llist_apply_with_argument(sorted_exts, (llist_apply_with_arg_func_t) print_extension_info, NULL TSRMLS_CC); zend_llist_destroy(sorted_exts); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c fastcgi.c
dmitry Tue Jul 15 13:11:19 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c fastcgi.c Log: Fixed bug #45423 (fastcgi parent process doesn't invoke php_module_shutdown before shutdown) (basant dot kukreja at sun dot com) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.19r2=1.267.2.15.2.50.2.20diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.19 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.20 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.19Mon Jun 23 11:37:50 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Jul 15 13:11:19 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.19 2008/06/23 11:37:50 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.20 2008/07/15 13:11:19 dmitry Exp $ */ #include php.h #include php_globals.h @@ -101,6 +101,12 @@ */ static int parent = 1; +/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */ +static int exit_signal = 0; + +/* Is Parent waiting for children to exit */ +static int parent_waiting = 0; + /** * Process group */ @@ -1225,6 +1231,7 @@ } /* }}} */ +#ifndef PHP_WIN32 /** * Clean up child processes upon exit */ @@ -1234,16 +1241,18 @@ fprintf(stderr, FastCGI shutdown, pid %d\n, getpid()); #endif -#ifndef PHP_WIN32 sigaction(SIGTERM, old_term, 0); /* Kill all the processes in our process group */ kill(-pgroup, SIGTERM); -#endif - /* We should exit at this point, but MacOSX doesn't seem to */ - exit(0); + if (parent parent_waiting) { + exit_signal = 1; + } else { + exit(0); + } } +#endif PHP_INI_BEGIN() STD_PHP_INI_ENTRY(cgi.rfc2616_headers, 0, PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals) @@ -1585,7 +1594,7 @@ } if (fcgi_in_shutdown()) { - exit(0); + goto parent_out; } while (parent) { @@ -1622,9 +1631,25 @@ #ifdef DEBUG_FASTCGI fprintf(stderr, Wait for kids, pid %d\n, getpid()); #endif - while (wait(status) 0) { + parent_waiting = 1; + while (1) { + if (wait(status) = 0) { + running--; + break; + } else if (exit_signal) { + break; + } + } + if (exit_signal) { +#if 0 + while (running 0) { + while (wait(status) 0) { + } + running--; + } +#endif + goto parent_out; } - running--; } } } else { @@ -2092,6 +2117,10 @@ #endif } +#ifndef PHP_WIN32 +parent_out: +#endif + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.3r2=1.4.2.13.2.28.2.4diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.3 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.4 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.3Thu Apr 3 10:24:58 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Jul 15 13:11:19 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.3 2008/04/03 10:24:58 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.4 2008/07/15 13:11:19 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -170,6 +170,20 @@ } } +static void fcgi_setup_signals(void) +{ + struct sigaction new_sa, old_sa; + + sigemptyset(new_sa.sa_mask); + new_sa.sa_flags = 0; + new_sa.sa_handler = fcgi_signal_handler; + sigaction(SIGUSR1, new_sa, NULL); + sigaction(SIGTERM, new_sa, NULL); + sigaction(SIGPIPE, NULL, old_sa); + if (old_sa.sa_handler == SIG_DFL) { + sigaction(SIGPIPE, new_sa, NULL); + } +} #endif int fcgi_in_shutdown(void) @@ -224,18 +238,7 @@ is_initialized = 1; errno = 0; if (getpeername(0, (struct sockaddr *)sa, len) != 0 errno ==
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Tue Jul 15 13:39:17 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fixed bug #45151 (Crash with URI/file..php (filename contains 2 dots)) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.20r2=1.267.2.15.2.50.2.21diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.20 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.21 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.20Tue Jul 15 13:11:19 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Jul 15 13:39:17 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.20 2008/07/15 13:11:19 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.21 2008/07/15 13:39:17 dmitry Exp $ */ #include php.h #include php_globals.h @@ -866,6 +866,39 @@ } /* }}} */ +/* {{{ is_valid_path + * + * some server configurations allow '..' to slip through in the + * translated path. We'll just refuse to handle such a path. + */ +static int is_valid_path(const char *path) +{ + const char *p; + + if (!path) { + return 0; + } + p = strstr(path, ..); + if (p) { + if ((p == path || IS_SLASH(*(p-1))) + (*(p+2) == 0 || IS_SLASH(*(p+2 { + return 0; + } + while (1) { + p = strstr(p+1, ..); + if (!p) { + break; + } + if (IS_SLASH(*(p-1)) + (*(p+2) == 0 || IS_SLASH(*(p+2 { + return 0; + } + } + } + return 1; +} +/* }}} */ + /* {{{ init_request_info initializes request_info structure @@ -1161,9 +1194,7 @@ if (pt) { efree(pt); } - /* some server configurations allow '..' to slip through in the - translated path. We'll just refuse to handle such a path. */ - if (script_path_translated !strstr(script_path_translated, ..)) { + if (is_valid_path(script_path_translated)) { SG(request_info).path_translated = estrdup(script_path_translated); } } else { @@ -1194,9 +1225,7 @@ } else { SG(request_info).request_uri = env_script_name; } - /* some server configurations allow '..' to slip through in the - translated path. We'll just refuse to handle such a path. */ - if (script_path_translated !strstr(script_path_translated, ..)) { + if (is_valid_path(script_path_translated)) { SG(request_info).path_translated = estrdup(script_path_translated); } free(real_path); @@ -1211,9 +1240,7 @@ if (!CGIG(discard_path) env_path_translated) { script_path_translated = env_path_translated; } - /* some server configurations allow '..' to slip through in the - translated path. We'll just refuse to handle such a path. */ - if (script_path_translated !strstr(script_path_translated, ..)) { + if (is_valid_path(script_path_translated)) { SG(request_info).path_translated = estrdup(script_path_translated); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Mon Jun 23 11:37:50 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Fixed possible buffer overflow http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.18r2=1.267.2.15.2.50.2.19diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.18 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.19 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.18Tue Apr 15 11:31:58 2008 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 23 11:37:50 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.18 2008/04/15 11:31:58 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.19 2008/06/23 11:37:50 dmitry Exp $ */ #include php.h #include php_globals.h @@ -723,12 +723,16 @@ (PG(user_ini_filename) *PG(user_ini_filename))) { /* Prepare search path */ path_len = strlen(SG(request_info).path_translated); - path = estrndup(SG(request_info).path_translated, path_len); - path_len = zend_dirname(path, path_len); /* Make sure we have trailing slash! */ - if (!IS_SLASH(path[path_len])) { + if (!IS_SLASH(SG(request_info).path_translated[path_len])) { + path = emalloc(path_len + 2); + memcpy(path, SG(request_info).path_translated, path_len + 1); + path_len = zend_dirname(path, path_len); path[path_len++] = DEFAULT_SLASH; + } else { + path = estrndup(SG(request_info).path_translated, path_len); + path_len = zend_dirname(path, path_len); } path[path_len] = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
iliaa Thu Feb 28 00:51:56 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFB: Fixed security issue detailed in CVE-2008-0599 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.12r2=1.267.2.15.2.50.2.13diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.12 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.13 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.12Fri Feb 15 14:45:42 2008 +++ php-src/sapi/cgi/cgi_main.c Thu Feb 28 00:51:56 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.12 2008/02/15 14:45:42 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.13 2008/02/28 00:51:56 iliaa Exp $ */ #include php.h #include php_globals.h @@ -1101,7 +1101,7 @@ ) { /* PATH_TRANSLATED = PATH_TRANSLATED - SCRIPT_NAME + PATH_INFO */ int ptlen = strlen(pt) - strlen(env_script_name); - int path_translated_len = ptlen + env_path_info ? strlen(env_path_info) : 0; + 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c fastcgi.c
dmitry Fri Feb 15 14:45:42 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c fastcgi.c Log: optimization http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.11r2=1.267.2.15.2.50.2.12diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.11 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.12 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.11Mon Dec 31 07:17:18 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 15 14:45:42 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.11 2007/12/31 07:17:18 sebastian Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.12 2008/02/15 14:45:42 dmitry Exp $ */ #include php.h #include php_globals.h @@ -756,7 +756,17 @@ 2. When the first call occurs and the request is not set up, flush fails on FastCGI. */ if (SG(sapi_started)) { - sapi_cgibin_flush(SG(server_context)); + if (fcgi_is_fastcgi()) { + if ( +#ifndef PHP_WIN32 + !parent +#endif + !fcgi_finish_request((fcgi_request*)SG(server_context))) { + php_handle_aborted_connection(); + } + } else { + sapi_cgibin_flush(SG(server_context)); + } } return SUCCESS; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.1r2=1.4.2.13.2.28.2.2diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.1 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.2 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.1Mon Dec 31 07:17:18 2007 +++ php-src/sapi/cgi/fastcgi.c Fri Feb 15 14:45:42 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.1 2007/12/31 07:17:18 sebastian Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.2 2008/02/15 14:45:42 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -632,7 +632,7 @@ } memcpy(tmp, p, name_len); tmp[name_len] = 0; - s = zend_strndup((char*)p + name_len, val_len); + s = estrndup((char*)p + name_len, val_len); zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); p += name_len + val_len; } @@ -644,7 +644,7 @@ static void fcgi_free_var(char **s) { - free(*s); + efree(*s); } static int fcgi_read_request(fcgi_request *req) @@ -657,7 +657,7 @@ req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; - zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 1); + zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); if (safe_read(req, hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version FCGI_VERSION_1) { @@ -693,15 +693,15 @@ req-keep = (((fcgi_begin_request*)buf)-flags FCGI_KEEP_CONN); switch fcgi_begin_request*)buf)-roleB1 8) + ((fcgi_begin_request*)buf)-roleB0) { case FCGI_RESPONDER: - val = strdup(RESPONDER); + val = estrdup(RESPONDER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_AUTHORIZER: - val = strdup(AUTHORIZER); + val = estrdup(AUTHORIZER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_FILTER: - val = strdup(FILTER); + val = estrdup(FILTER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; default: @@ -1168,11 +1168,13 @@ int fcgi_finish_request(fcgi_request *req) { + int ret = 1; + if (req-fd = 0) { - fcgi_flush(req, 1); + ret = fcgi_flush(req, 1); fcgi_close(req, 0, 1); } - return 1; + return ret; } char* fcgi_getenv(fcgi_request *req, const char* var, int var_len) @@ -1195,7 +1197,7 @@ } else { char **ret; - val = strdup(val); + val = estrdup(val); if (zend_hash_update(req-env, var, var_len+1, val, sizeof(char*), (void**)ret) == SUCCESS) {
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Mon Dec 3 09:38:12 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: The -f option is fixed to work in the same way as in CLI sapi http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.9r2=1.267.2.15.2.50.2.10diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.9 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.10 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.9 Fri Nov 9 16:27:43 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Dec 3 09:38:12 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.9 2007/11/09 16:27:43 jani Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.10 2007/12/03 09:38:12 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1690,12 +1690,12 @@ } script_file = estrdup(php_optarg); no_headers = 1; - /* arguments after the file are considered script args */ - SG(request_info).argc = argc - (php_optind - 1); - SG(request_info).argv = argv[php_optind - 1]; break; case 'i': /* php info quit */ + if (script_file) { + efree(script_file); + } if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -1716,6 +1716,9 @@ break; case 'm': /* list compiled in modules */ + if (script_file) { + efree(script_file); + } php_output_startup(); php_output_activate(TSRMLS_C); SG(headers_sent) = 1; @@ -1739,6 +1742,9 @@ break; case 'v': /* show php version quit */ + if (script_file) { + efree(script_file); + } no_headers = 1; if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; @@ -1775,6 +1781,18 @@ /* override path_translated if -f on command line */ STR_FREE(SG(request_info).path_translated); SG(request_info).path_translated = script_file; + /* before registering argv to module exchange the *new* argv[0] */ + /* we can achieve this without allocating more memory */ + SG(request_info).argc = argc - (php_optind - 1); + SG(request_info).argv = argv[php_optind - 1]; + SG(request_info).argv[0] = script_file; + } else if (argc php_optind) { + /* file is on command line, but not in -f opt */ + STR_FREE(SG(request_info).path_translated); + SG(request_info).path_translated = estrdup(argv[php_optind++]); + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - php_optind; + SG(request_info).argv = argv[php_optind]; } if (no_headers) { @@ -1782,14 +1800,6 @@ SG(request_info).no_headers = 1;
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
janiThu Oct 25 10:01:31 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: ws http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.5r2=1.267.2.15.2.50.2.6diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.5 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.6 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.5 Thu Oct 25 05:39:06 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 25 10:01:30 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.5 2007/10/25 05:39:06 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.6 2007/10/25 10:01:30 jani Exp $ */ #include php.h #include php_globals.h @@ -760,7 +760,7 @@ -v Version number\n -w Display source with stripped comments and whitespace.\n -z fileLoad Zend extension file.\n --T count Measure execution time of script repeated count times.\n, + -T count Measure execution time of script repeated count times.\n, prog, prog); } /* }}} */ @@ -1539,7 +1539,7 @@ while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1, 2)) != -1) { switch (c) { case 'T': - benchmark = 1; + benchmark = 1; repeats = atoi(php_optarg); gettimeofday(start, NULL); break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
dmitry Fri Oct 26 04:46:13 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: Added check for HAVE_GETTIMEOFDAY http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.6r2=1.267.2.15.2.50.2.7diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.6 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.7 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.6 Thu Oct 25 10:01:30 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Oct 26 04:46:12 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.6 2007/10/25 10:01:30 jani Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.7 2007/10/26 04:46:12 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1261,7 +1261,11 @@ fcgi_request request; int repeats = 1; int benchmark = 0; +#if HAVE_GETTIMEOFDAY struct timeval start, end; +#else + time_t start, end; +#endif #ifndef PHP_WIN32 int status = 0; #endif @@ -1541,7 +1545,11 @@ case 'T': benchmark = 1; repeats = atoi(php_optarg); +#ifdef HAVE_GETTIMEOFDAY gettimeofday(start, NULL); +#else + time(start); +#endif break; case 'h': case '?': @@ -1960,6 +1968,7 @@ out: if (benchmark) { int sec; +#ifdef HAVE_GETTIMEOFDAY int usec; gettimeofday(end, NULL); @@ -1971,6 +1980,11 @@ usec = (int)(end.tv_usec + 100 - start.tv_usec); } fprintf(stderr, \nElapsed time: %d.%06d sec\n, sec, usec); +#else + time(end); + sec = (int)(end - start); + fprintf(stderr, \nElapsed time: %d sec\n, sec); +#endif } SG(server_context) = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c
janiThu Sep 27 22:09:46 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/sapi/cgi cgi_main.c Log: MFH: ws + cs http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.1r2=1.267.2.15.2.50.2.2diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.1 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.2 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.1 Thu Sep 27 08:23:58 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Sep 27 22:09:46 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.1 2007/09/27 08:23:58 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.2 2007/09/27 22:09:46 jani Exp $ */ #include php.h #include php_globals.h @@ -83,8 +83,7 @@ #include fastcgi.h #ifndef PHP_WIN32 -/* XXX this will need to change later when threaded fastcgi is - implemented. shane */ +/* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; #endif @@ -187,8 +186,8 @@ Bucket *f = *((Bucket **) a); Bucket *s = *((Bucket **) b); - return strcasecmp(((zend_module_entry *)f-pData)-name, - ((zend_module_entry *)s-pData)-name); + return strcasecmp( ((zend_module_entry *)f-pData)-name, + ((zend_module_entry *)s-pData)-name); } static void print_modules(TSRMLS_D) @@ -209,11 +208,10 @@ return 0; } -static int extension_name_cmp(const zend_llist_element **f, - const zend_llist_element **s TSRMLS_DC) +static int extension_name_cmp(const zend_llist_element **f, const zend_llist_element **s TSRMLS_DC) { - return strcmp(((zend_extension *)(*f)-data)-name, - ((zend_extension *)(*s)-data)-name); + return strcmp( ((zend_extension *)(*f)-data)-name, + ((zend_extension *)(*s)-data)-name); } static void print_extensions(TSRMLS_D) @@ -312,8 +310,7 @@ int len; if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { - len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, - %s\r\n, SG(sapi_headers).http_status_line); + len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); if (len SAPI_CGI_MAX_HEADER_LENGTH) { len = SAPI_CGI_MAX_HEADER_LENGTH; @@ -323,9 +320,10 @@ char *s; if (SG(sapi_headers).http_status_line - (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 - (s - SG(sapi_headers).http_status_line) = 5 - strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0) { + (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 + (s - SG(sapi_headers).http_status_line) = 5 + strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0 + ) { len = slprintf(buf, sizeof(buf), Status:%s\r\n, s); } else { len = slprintf(buf, sizeof(buf), Status: %d\r\n, SG(sapi_headers).http_response_code); @@ -453,18 +451,20 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { if (PG(http_globals)[TRACK_VARS_ENV] - array_ptr != PG(http_globals)[TRACK_VARS_ENV] - Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0) { + array_ptr != PG(http_globals)[TRACK_VARS_ENV] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0 + ) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } else if (PG(http_globals)[TRACK_VARS_SERVER] - array_ptr != PG(http_globals)[TRACK_VARS_SERVER] - Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0) { + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0 + )