You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dg...@hyperreal.org on 1999/05/13 21:00:49 UTC

cvs commit: apache-1.3/src/modules/standard mod_include.c mod_autoindex.c

dgaudet     99/05/13 12:00:48

  Modified:    src/modules/standard mod_include.c mod_autoindex.c
  Log:
  Back out the "evil hack" portion of Raymond's patch.  In addition to being
  an evil hack, it causes memory corruption.  You cannot destroy a #included
  subrequest of mod_include... look for all uses of "request_config" in
  mod_include, in particular look at the code around the ap_join_pool call.
  
  Revision  Changes    Path
  1.116     +9 -40     apache-1.3/src/modules/standard/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_include.c,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- mod_include.c	1999/05/13 18:25:57	1.115
  +++ mod_include.c	1999/05/13 19:00:41	1.116
  @@ -108,6 +108,9 @@
   
   module MODULE_VAR_EXPORT includes_module;
   
  +/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
  +#define NESTED_INCLUDE_MAGIC	(&includes_module)
  +
   /* ------------------------ Environment function -------------------------- */
   
   /* XXX: could use ap_table_overlap here */
  @@ -743,7 +746,9 @@
               }
   
   	    /* destroy the sub request if it's not a nested include */
  -	    if (rr != NULL) {
  +            if (rr != NULL
  +		&& ap_get_module_config(rr->request_config, &includes_module)
  +		    != NESTED_INCLUDE_MAGIC) {
   		ap_destroy_sub_req(rr);
               }
           }
  @@ -2371,41 +2376,6 @@
           return OK;
       }
   
  -#define SUB_REQ_STRING	"Sub request to mod_include"
  -#define PARENT_STRING	"Parent request to mod_include"
  -
  -    if (ap_table_get(r->notes, SUB_REQ_STRING) != NULL) {
  -	request_rec *p = r->main;
  -
  -	/*
  -	 * The note is a flag to mod_include that this request is actually
  -	 * a subrequest from another module and that mod_include needs to
  -	 * treat it as if it's a subrequest from mod_include.
  -	 *
  -	 * HACK ALERT!
  -	 * There is no good way to pass the parent request_rec to mod_include.
  -	 * Tables only take string values and there is nowhere appropriate in
  -	 * in the request_rec that can safely be used.
  -	 *
  -	 * So we search up the chain of requests and redirects looking for
  -	 * the parent request.
  -	 */
  -
  -	while (p) {
  -	    if (ap_table_get(p->notes, PARENT_STRING) != NULL) {
  -		/* Kludge --- See below */
  -		ap_set_module_config(r->request_config, &includes_module, p);
  -
  -		ap_add_common_vars(p);
  -		ap_add_cgi_vars(p);
  -		add_include_vars(p, DEFAULT_TIME_FORMAT);
  -		ap_table_unset(r->notes, SUB_REQ_STRING);
  -		break;
  -	    }
  -	    p = (p->prev) ? p->prev : p->main;
  -	}
  -    }
  -
       if ((parent = ap_get_module_config(r->request_config, &includes_module))) {
   	/* Kludge --- for nested includes, we want to keep the subprocess
   	 * environment of the base document (for compatibility); that means
  @@ -2441,10 +2411,9 @@
       send_parsed_content(f, r);
   
       if (parent) {
  -	/* Kludge --- Doing this allows the caller to safely destroy the
  -	 * sub_req
  -	 */
  -	r->pool = ap_make_sub_pool(r->pool);
  +	/* signify that the sub request should not be killed */
  +	ap_set_module_config(r->request_config, &includes_module,
  +	    NESTED_INCLUDE_MAGIC);
       }
   
       ap_kill_timeout(r);
  
  
  
  1.108     +0 -8      apache-1.3/src/modules/standard/mod_autoindex.c
  
  Index: mod_autoindex.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- mod_autoindex.c	1999/05/13 18:25:56	1.107
  +++ mod_autoindex.c	1999/05/13 19:00:43	1.108
  @@ -924,10 +924,6 @@
       ap_rputs("</PRE>\n", r);
   }
   
  -/* See mod_include */
  -#define SUB_REQ_STRING	"Sub request to mod_include"
  -#define PARENT_STRING	"Parent request to mod_include"
  -
   /*
    * Handle the preamble through the H1 tag line, inclusive.  Locate
    * the file with a subrequests.  Process text/html documents by actually
  @@ -969,8 +965,6 @@
   		if (! suppress_amble) {
   		    emit_preamble(r, title);
   		}
  -		ap_table_add(r->notes, PARENT_STRING, "");
  -		ap_table_add(rr->notes, SUB_REQ_STRING, "");
   		/*
   		 * If there's a problem running the subrequest, display the
   		 * preamble if we didn't do it before -- the header file
  @@ -1045,8 +1039,6 @@
   	 */
   	if (rr->content_type != NULL) {
   	    if (!strcasecmp("text/html", rr->content_type)) {
  -		ap_table_add(r->notes, PARENT_STRING, "");
  -		ap_table_add(rr->notes, SUB_REQ_STRING, "");
   		if (ap_run_sub_req(rr) == OK) {
   		    /* worked... */
   		    suppress_sig = 1;