From: Zeev Suraski Date: Sun, 13 May 2001 09:03:46 +0000 (+0000) Subject: Safer detection of recursive PHP invocations X-Git-Tag: PRE_GRANULAR_GARBAGE_FIX~445 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01132639911a5d36dce43cfe06cafa7e21cec1c4;p=php Safer detection of recursive PHP invocations --- diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index 54aea59e6e..cfff789b20 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -285,7 +285,9 @@ static void php_apache_log_message(char *message) static void php_apache_request_shutdown(void *dummy) { SLS_FETCH(); + APLS_FETCH(); + AP(in_request)=0; SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */ php_request_shutdown(dummy); } @@ -446,7 +448,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) PLS_FETCH(); APLS_FETCH(); - if (r->assbackwards && r->protocol && !strcmp(r->protocol, "INCLUDED")) { + if (AP(in_request)) { zend_file_handle fh; fh.filename = r->filename; @@ -456,6 +458,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) zend_execute_scripts(ZEND_INCLUDE CLS_CC ELS_CC, 1, &fh); return OK; } + AP(in_request)=1; if (setjmp(EG(bailout))!=0) { return OK; diff --git a/sapi/apache/mod_php4.h b/sapi/apache/mod_php4.h index f3fcc143e3..c70d09a5a8 100644 --- a/sapi/apache/mod_php4.h +++ b/sapi/apache/mod_php4.h @@ -31,6 +31,7 @@ typedef struct { long last_modified; long xbithack; long terminate_child; + zend_bool in_request; } php_apache_info_struct; extern zend_module_entry apache_module_entry; diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index 2ae7dca282..9a055d76a3 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -89,10 +89,19 @@ PHP_INI_BEGIN() PHP_INI_END() + +static void php_apache_globals_ctor(php_apache_info_struct *apache_globals) +{ + apache_globals->in_request = 0; +} + + static PHP_MINIT_FUNCTION(apache) { #ifdef ZTS - php_apache_info_id = ts_allocate_id(sizeof(php_apache_info_struct), NULL, NULL); + php_apache_info_id = ts_allocate_id(sizeof(php_apache_info_struct), ts_allocate_ctor, NULL); +#else + php_apache_globals_ctor(&php_apache_info); #endif REGISTER_INI_ENTRIES(); return SUCCESS;