1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

When concatting for PPR, avoid cases where we

concat ".../" and "/..." to create "...//..."

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1386576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Jagielski
2012-09-17 12:11:45 +00:00
parent 089f0eb0ac
commit df145fa817

View File

@@ -859,6 +859,7 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
if (ap_proxy_valid_balancer_name((char *)real, 0) && if (ap_proxy_valid_balancer_name((char *)real, 0) &&
(balancer = ap_proxy_get_balancer(r->pool, sconf, real, 1))) { (balancer = ap_proxy_get_balancer(r->pool, sconf, real, 1))) {
int n, l3 = 0; int n, l3 = 0;
int fake_endwslash = (ent[i].fake[strlen(ent[i].fake)-1] == '/');
proxy_worker **worker = (proxy_worker **)balancer->workers->elts; proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
const char *urlpart = ap_strchr_c(real + sizeof(BALANCER_PREFIX) - 1, '/'); const char *urlpart = ap_strchr_c(real + sizeof(BALANCER_PREFIX) - 1, '/');
if (urlpart) { if (urlpart) {
@@ -881,12 +882,20 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
if (l1 >= l2 + l3 if (l1 >= l2 + l3
&& strncasecmp((*worker)->s->name, url, l2) == 0 && strncasecmp((*worker)->s->name, url, l2) == 0
&& strncmp(urlpart, url + l2, l3) == 0) { && strncmp(urlpart, url + l2, l3) == 0) {
/* Avoid double-slash when concatting */
if (fake_endwslash && (url[l2 + l3] == '/')) {
l2++;
}
u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3], u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3],
NULL); NULL);
return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r); return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r);
} }
} }
else if (l1 >= l2 && strncasecmp((*worker)->s->name, url, l2) == 0) { else if (l1 >= l2 && strncasecmp((*worker)->s->name, url, l2) == 0) {
/* Avoid double-slash when concatting */
if (fake_endwslash && (url[l2] == '/')) {
l2++;
}
u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL); u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r); return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r);
} }