From: Joe Orton Date: Fri, 6 Jun 2008 14:44:35 +0000 (+0000) Subject: No functional change; simplify the CVE-2007-6420 fix slightly, as X-Git-Tag: 2.3.0~545 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce75fb285cd93533233b6dafd7ba77127fcbecb7;p=apache No functional change; simplify the CVE-2007-6420 fix slightly, as suggested by rpluem: * modules/proxy/mod_proxy_balancer.c (balancer_init): Serialize the UUID to a string here... (balancer_handler): ...rather than here. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@663967 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 58858841a5..ffa9bf5c5e 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -25,7 +25,7 @@ module AP_MODULE_DECLARE_DATA proxy_balancer_module; -static apr_uuid_t balancer_nonce; +static char balancer_nonce[APR_UUID_FORMATTED_LENGTH + 1]; static int proxy_balancer_canon(request_rec *r, char *url) { @@ -628,6 +628,7 @@ static int balancer_init(apr_pool_t *p, apr_pool_t *plog, { void *data; const char *userdata_key = "mod_proxy_balancer_init"; + apr_uuid_t uuid; /* balancer_init() will be called twice during startup. So, only * set up the static data the second time through. */ @@ -638,7 +639,10 @@ static int balancer_init(apr_pool_t *p, apr_pool_t *plog, return OK; } - apr_uuid_get(&balancer_nonce); + /* Retrieve a UUID and store the nonce for the lifetime of + * the process. */ + apr_uuid_get(&uuid); + apr_uuid_format(balancer_nonce, &uuid); return OK; } @@ -656,9 +660,6 @@ static int balancer_handler(request_rec *r) int access_status; int i, n; const char *name; - char nonce[APR_UUID_FORMATTED_LENGTH + 1]; - - apr_uuid_format(nonce, &balancer_nonce); /* is this for us? */ if (strcmp(r->handler, "balancer-manager")) @@ -692,7 +693,7 @@ static int balancer_handler(request_rec *r) /* Check that the supplied nonce matches this server's nonce; * otherwise ignore all parameters, to prevent a CSRF attack. */ if ((name = apr_table_get(params, "nonce")) == NULL - || strcmp(nonce, name) != 0) { + || strcmp(balancer_nonce, name) != 0) { apr_table_clear(params); } @@ -833,7 +834,7 @@ static int balancer_handler(request_rec *r) ap_rvputs(r, "\nuri, "?b=", balancer->name + sizeof("balancer://") - 1, "&w=", ap_escape_uri(r->pool, worker->name), - "&nonce=", nonce, + "&nonce=", balancer_nonce, "\">", NULL); ap_rvputs(r, worker->name, "", NULL); ap_rvputs(r, "", ap_escape_html(r->pool, worker->s->route), @@ -897,8 +898,8 @@ static int balancer_handler(request_rec *r) ap_rvputs(r, "name + sizeof("balancer://") - 1, "\">\n\n", NULL); - ap_rvputs(r, "\n", - NULL); + ap_rvputs(r, "\n", NULL); ap_rputs("
\n", r); } ap_rputs(ap_psignature("",r), r);