From 8c4ab615479b0af167b82db5fb2a9b83a054ff1c Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 30 May 2014 13:51:39 +0000 Subject: [PATCH] Merge r1592511, r1592514 from trunk: reformat only (get rid of unnecessary block scope) Clarify an existing requirement of the server_portstr parameter to ap_proxy_determine_connection(): it must be a buffer of at least one byte in size. (And don't bother with using strcpy in order to zap a string.) Submitted by: trawick Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1598605 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 11 ----------- modules/proxy/mod_proxy.h | 5 +++-- modules/proxy/proxy_util.c | 18 +++++++++--------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/STATUS b/STATUS index c33a3a9b87..b4e291e2a9 100644 --- a/STATUS +++ b/STATUS @@ -100,17 +100,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * minor proxy_util cleanups: - . get rid of unnecessary block scope - . Clarify an existing requirement of the server_portstr parameter - to ap_proxy_determine_connection(): it must be a buffer of at - least one byte in size. (And don't bother with using strcpy in - order to zap a string.) - trunk patches: http://svn.apache.org/viewvc?view=revision&revision=r1592511 - http://svn.apache.org/viewvc?view=revision&revision=r1592514 - 2.4.x patches: trunk patches work - +1: trawick, ylavic, jim - PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 585ace89eb..4ead22e701 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -797,8 +797,9 @@ PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker, * @param url request url * @param proxyname are we connecting directly or via a proxy * @param proxyport proxy host port - * @param server_portstr Via headers server port - * @param server_portstr_size size of the server_portstr buffer + * @param server_portstr Via headers server port, must be non-NULL + * @param server_portstr_size size of the server_portstr buffer; must + * be at least one, even if the protocol doesn't use this * @return OK or HTTP_XXX error */ PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 3dd12ca329..a81848c9da 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2329,16 +2329,16 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, } /* Get the server port for the Via headers */ - { - server_port = ap_get_server_port(r); - if (ap_is_default_port(server_port, r)) { - strcpy(server_portstr,""); - } - else { - apr_snprintf(server_portstr, server_portstr_size, ":%d", - server_port); - } + server_port = ap_get_server_port(r); + AP_DEBUG_ASSERT(server_portstr_size > 0); + if (ap_is_default_port(server_port, r)) { + server_portstr[0] = '\0'; } + else { + apr_snprintf(server_portstr, server_portstr_size, ":%d", + server_port); + } + /* check if ProxyBlock directive on this host */ if (OK != ap_proxy_checkproxyblock2(r, conf, uri->hostname, proxyname ? NULL : conn->addr)) { -- 2.50.1