From: Graham Leggett Date: Wed, 13 Oct 2004 17:23:12 +0000 (+0000) Subject: mod_rewrite: Handle per-location rules when r->filename is unset. X-Git-Tag: 2.0.53~221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee2df2525153d83f222d7483aaa46034ea63946a;p=thirdparty%2Fapache%2Fhttpd.git mod_rewrite: Handle per-location rules when r->filename is unset. Previously this would segfault or simply not match as expected, depending on the platform. PR: Obtained from: Submitted by: trawick Reviewed by: trawick, geoff, jerenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@105434 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b403961f02f..8413256f02f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 2.0.53 + *) mod_rewrite: Handle per-location rules when r->filename is unset. + Previously this would segfault or simply not match as expected, + depending on the platform. [Jeff Trawick] + *) mod_rewrite: Fix query string handling for proxied URLs. PR 14518. [michael teitler , Jan Kratochvil ] diff --git a/STATUS b/STATUS index 4b38165c3f5..dc8b48af513 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/10/13 17:12:08 $] +Last modified at [$Date: 2004/10/13 17:23:10 $] Release: @@ -138,12 +138,6 @@ PATCHES TO BACKPORT FROM 2.1 +1: nd, jerenkrantz, minfrin minfrin: applied to v2.0 - *) mod_rewrite: Handle per-location rules when r->filename is unset. - Previously this would segfault or simply not match as expected, - depending on the platform. - modules/mappers/mod_rewrite.c: r1.260 - +1: trawick, geoff, jerenkrantz - *) mod_headers: Support {...}s tag for SSL variable lookup. http://www.apache.org/~jorton/mod_headers-2.0-ssl.diff +1: jorton, trawick diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 6a5c3b38d03..42fdddb3f42 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -1477,9 +1477,17 @@ static int hook_fixup(request_rec *r) * remember the current filename before rewriting for later check * to prevent deadlooping because of internal redirects * on final URL/filename which can be equal to the inital one. + * also, we'll restore original r->filename if we decline this + * request */ ofilename = r->filename; + if (r->filename == NULL) { + r->filename = apr_pstrdup(r->pool, r->uri); + rewritelog((r, 2, "init rewrite engine with requested uri %s", + r->filename)); + } + /* * now apply the rules ... */ @@ -1631,7 +1639,7 @@ static int hook_fixup(request_rec *r) * use the following internal redirection stuff because * this would lead to a deadloop. */ - if (strcmp(r->filename, ofilename) == 0) { + if (ofilename != NULL && strcmp(r->filename, ofilename) == 0) { rewritelog(r, 1, "[per-dir %s] initial URL equal rewritten " "URL: %s [IGNORING REWRITE]", dconf->directory, r->filename); @@ -1688,6 +1696,7 @@ static int hook_fixup(request_rec *r) else { rewritelog(r, 1, "[per-dir %s] pass through %s", dconf->directory, r->filename); + r->filename = ofilename; return DECLINED; } }