From: Jim Jagielski Date: Fri, 3 Aug 2007 12:44:03 +0000 (+0000) Subject: Merge r559804 from trunk: X-Git-Tag: 2.2.5~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2def3e8797a033ffc9e4d0078e38fe455b111c94;p=thirdparty%2Fapache%2Fhttpd.git Merge r559804 from trunk: mod_filter: fix merging of ! and = PR: 42186 - patch by Issac Goldstand Submitted by: niq Reviewed by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@562441 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 9378e9e34ba..b3df3e34f88 100644 --- a/STATUS +++ b/STATUS @@ -77,12 +77,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_filter: fix merging of ! and = in FilterChain - PR: 42186 - patch by Issac Goldstand - http://svn.apache.org/viewvc?view=rev&revision=559804 - http://svn.apache.org/viewvc?view=rev&revision=559840 (CHANGES) - +1: niq, rpluem, jim - * mod_filter: fix integer comparisons PR: 41835 http://svn.apache.org/viewvc?view=rev&revision=559837 diff --git a/modules/filters/mod_filter.c b/modules/filters/mod_filter.c index ae167178ce1..9b59fc8c340 100644 --- a/modules/filters/mod_filter.c +++ b/modules/filters/mod_filter.c @@ -688,12 +688,20 @@ static const char *filter_chain(cmd_parms *cmd, void *CFG, const char *arg) break; case '!': /* Empty the chain */ - cfg->chain = NULL; + /** IG: Add a NULL provider to the beginning so that + * we can ensure that we'll empty everything before + * this when doing config merges later */ + p = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain)); + p->fname = NULL; + cfg->chain = p; break; case '=': /* initialise chain with this arg */ + /** IG: Prepend a NULL provider to the beginning as above */ p = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain)); - p->fname = arg+1; + p->fname = NULL; + p->next = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain)); + p->next->fname = arg+1; cfg->chain = p; break; @@ -739,6 +747,14 @@ static void filter_insert(request_rec *r) ap_set_module_config(r->request_config, &filter_module, ctx); #endif + /** IG: Now that we've merged to the final config, go one last time + * through the chain, and prune out the NULL filters */ + + for (p = cfg->chain; p; p = p->next) { + if (p->fname == NULL) + cfg->chain = p->next; + } + for (p = cfg->chain; p; p = p->next) { filter = apr_hash_get(cfg->live_filters, p->fname, APR_HASH_KEY_STRING); if (filter == NULL) { @@ -788,7 +804,10 @@ static void *filter_merge(apr_pool_t *pool, void *BASE, void *ADD) if (base->chain && add->chain) { for (p = base->chain; p; p = p->next) { newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain)); - if (savelink) { + if (newlink->fname == NULL) { + conf->chain = savelink = newlink; + } + else if (savelink) { savelink->next = newlink; savelink = newlink; } @@ -799,8 +818,17 @@ static void *filter_merge(apr_pool_t *pool, void *BASE, void *ADD) for (p = add->chain; p; p = p->next) { newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain)); - savelink->next = newlink; - savelink = newlink; + /** Filter out merged chain resets */ + if (newlink->fname == NULL) { + conf->chain = savelink = newlink; + } + else if (savelink) { + savelink->next = newlink; + savelink = newlink; + } + else { + conf->chain = savelink = newlink; + } } } else if (add->chain) {