]> granicus.if.org Git - php/commitdiff
Safer detection of recursive PHP invocations
authorZeev Suraski <zeev@php.net>
Sun, 13 May 2001 09:03:46 +0000 (09:03 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 13 May 2001 09:03:46 +0000 (09:03 +0000)
sapi/apache/mod_php4.c
sapi/apache/mod_php4.h
sapi/apache/php_apache.c

index 54aea59e6e75232acbb78286f088f1da5b70e0d5..cfff789b20e6eeed5e3aaf091fc5d3634c35c1f3 100644 (file)
@@ -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;
index f3fcc143e30685b80a86873390bd53ac278bf837..c70d09a5a811c1642d66171bceebc265bbc6e99a 100644 (file)
@@ -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;
index 2ae7dca282076e755c70522d0143155a65452306..9a055d76a3ff61110b9abf712a1c3cab42b1a342 100644 (file)
@@ -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;