This is an automated email from the ASF dual-hosted git repository. ChristopherSchultz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat-connectors.git
commit 2e4c7fedbc08d8d61c610df876c3db6833161022 Author: Christopher Schultz <[email protected]> AuthorDate: Mon Jun 8 11:25:56 2026 -0400 Always use 'size' passed-in from the caller Remove temporary string 'pb' and print directly to the output buffer --- native/common/jk_connect.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c index 3fefd1d81..58172a9e7 100644 --- a/native/common/jk_connect.c +++ b/native/common/jk_connect.c @@ -1285,24 +1285,31 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) */ char *jk_dump_hinfo(jk_sockaddr_t *saddr, char *buf, size_t size) { - char pb[8]; + if (size == 0) { + return buf; + } if (saddr->ipaddr_ptr == NULL) { - strcpy(buf, "UnresolvedIP"); + snprintf(buf, size, "UnresolvedIP"); } else { + const char *ret; + if (saddr->family == JK_INET) { - inet_ntop4(saddr->ipaddr_ptr, buf, size); + ret = inet_ntop4(saddr->ipaddr_ptr, buf, size); } #if JK_HAVE_IPV6 else { - inet_ntop6(saddr->ipaddr_ptr, buf, size); + ret = inet_ntop6(saddr->ipaddr_ptr, buf, size); } #endif + if (ret == NULL) { + snprintf(buf, size, "InvalidIP"); + } } - sprintf(pb, ":%d", saddr->port); - strncat(buf, pb, size - strlen(buf) - 1); + size_t len = strlen(buf); + snprintf(buf + len, size - len, ":%d", saddr->port); return buf; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
