From: Ruediger Pluem Date: Sun, 3 Dec 2006 21:24:43 +0000 (+0000) Subject: * Ensure that at least scheme://hostname[:port] matches between worker and URL X-Git-Tag: 2.3.0~1999 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27f7eda66390dcbb31986b0b5d9c2f6d7fc5e7ba;p=thirdparty%2Fapache%2Fhttpd.git * Ensure that at least scheme://hostname[:port] matches between worker and URL when trying to find the worker that fits best to the given URL. PR: 40910 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@481901 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 704408cece5..c8c87acd3fe 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) mod_proxy: Ensure that at least scheme://hostname[:port] matches between + worker and URL when searching for the best fitting worker for a given URL. + PR 40910. [Ruediger Pluem] + *) mod_cache: Remove expired content from cache that cannot be revalidated. PR 30370. [Ruediger Pluem] diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 6b2ffd46630..e8be508ab81 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1324,6 +1324,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, proxy_worker *max_worker = NULL; int max_match = 0; int url_length; + int min_match; int worker_name_length; const char *c; char *url_copy; @@ -1349,20 +1350,25 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, pathstart = url_copy + (c - url); *pathstart = '\0'; ap_str_tolower(url_copy); + min_match = strlen(url_copy); *pathstart = '/'; } else { ap_str_tolower(url_copy); + min_match = strlen(url_copy); } worker = (proxy_worker *)conf->workers->elts; /* * Do a "longest match" on the worker name to find the worker that - * fits best to the URL. + * fits best to the URL, but keep in mind that we must have at least + * a minimum matching of length min_match such that + * scheme://hostname[:port] matches between worker and url. */ for (i = 0; i < conf->workers->nelts; i++) { if ( ((worker_name_length = strlen(worker->name)) <= url_length) + && (worker_name_length >= min_match) && (worker_name_length > max_match) && (strncmp(url_copy, worker->name, worker_name_length) == 0) ) { max_worker = worker;