From a306773aa4b12f9d4c6f15dcbd2405c7067c01af Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 5 May 2014 12:47:18 +0000 Subject: [PATCH] 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.) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1592514 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.h | 5 +++-- modules/proxy/proxy_util.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index f55f42899e..3e63e24560 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -806,8 +806,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 9eb6aa80b6..917ee8db38 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2329,8 +2329,9 @@ 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); + AP_DEBUG_ASSERT(server_portstr_size > 0); if (ap_is_default_port(server_port, r)) { - strcpy(server_portstr,""); + server_portstr[0] = '\0'; } else { apr_snprintf(server_portstr, server_portstr_size, ":%d", -- 2.40.0