You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2026/06/09 13:44:13 UTC
(tomcat-connectors) branch main updated (d3a74c15d -> ed383e12c)
This is an automated email from the ASF dual-hosted git repository.
ChristopherSchultz pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-connectors.git
from d3a74c15d Add AGENTS.md and SECURITY.md to support AI security scans
new 2e4c7fedb Always use 'size' passed-in from the caller
new 101ddeec5 Return existing pool on shrink-request
new 197c7baf3 Avoid overflow on alignment adjustment
new 0d66c7de3 Use snprintf when printing port numbers
new 3cc048f50 Use correct conversion for unsigned int
new 7966dd1e4 Use sockaddr_storage to ensure we have enough space for IPv6
new 412cb1e32 Don't assume IPv6 when not IPv4
new cebc3142e Fix typo
new 84506485f Move the else outside of the ifdef
new 7dfc55913 Use correct blocking around ifdefs
new 8e9fefef6 Always check sizes
new 6d69b5485 Slight cleanup
new e6e066ed7 Respect the return value from inet_ntop4/inet_ntop6
new 7b57bf6a2 Remove unnecessary null-terminators
new 53506d4b8 Improve performance
new 83c4ef518 Improve performance
new 730680fbb Make macro definition a little safer
new 21987720d Add overrun protection
new 1c5b840ce Avoid unlikely underflow
new ed383e12c Fix a few issues in jk_sb_send
The 20 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
native/common/jk_ajp12_worker.c | 4 +-
native/common/jk_connect.c | 112 ++++++++++++++++++++++++++++------------
native/common/jk_map.c | 90 ++++++++++++++++++--------------
native/common/jk_pool.c | 7 ++-
native/common/jk_sockbuf.c | 76 ++++++++++++++++++++++-----
5 files changed, 200 insertions(+), 89 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 08/20: Fix typo
Posted by sc...@apache.org.
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 cebc3142e8831f496169718f404e4ee37088c8f6
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 13:01:11 2026 -0400
Fix typo
---
native/common/jk_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/native/common/jk_pool.c b/native/common/jk_pool.c
index 9adbfa761..3c4ccf714 100644
--- a/native/common/jk_pool.c
+++ b/native/common/jk_pool.c
@@ -65,7 +65,7 @@ void *jk_pool_alloc(jk_pool_t *p, size_t size)
if (size == 0)
return NULL;
- if (sz > SIZE_MAX - JK_ALIGN_DEFAULT(1)) {
+ if (size > SIZE_MAX - JK_ALIGN_DEFAULT(1)) {
return NULL;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 17/20: Make macro definition a little safer
Posted by sc...@apache.org.
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 730680fbbaeea97162537422c536f7391d6fb0f3
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 16:28:44 2026 -0400
Make macro definition a little safer
---
native/common/jk_map.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/native/common/jk_map.c b/native/common/jk_map.c
index 116efd868..812c04853 100644
--- a/native/common/jk_map.c
+++ b/native/common/jk_map.c
@@ -74,13 +74,13 @@
* -- Ralf S. Engelschall <rs...@engelschall.com>
*/
#define COMPUTE_KEY_HASH(key, hash) \
-{ \
- const unsigned char *p; \
- hash = 0; \
- for (p = (const unsigned char *)key; *p; p++) { \
- hash = hash * 33 + *p; \
- } \
-}
+do { \
+ const unsigned char *p; \
+ (hash) = 0u; \
+ for (p = (const unsigned char *)(key); *p; p++) { \
+ (hash) = (hash) * 33u + *p; \
+ } \
+} while(0)
static volatile int global_map_id = 0;
static void trim_prp_comment(char *prp);
@@ -149,7 +149,7 @@ void *jk_map_get(jk_map_t *m, const char *name, const void *def)
if (m && name) {
unsigned int i;
unsigned int hash;
- COMPUTE_KEY_HASH(name, hash)
+ COMPUTE_KEY_HASH(name, hash);
for (i = 0; i < m->size; i++) {
if (m->keys[i] == hash && strcmp(m->names[i], name) == 0) {
rc = m->values[i];
@@ -167,7 +167,7 @@ int jk_map_get_id(jk_map_t *m, const char *name)
if (m && name) {
unsigned int i;
unsigned int hash;
- COMPUTE_KEY_HASH(name, hash)
+ COMPUTE_KEY_HASH(name, hash);
for (i = 0; i < m->size; i++) {
if (m->keys[i] == hash && strcmp(m->names[i], name) == 0) {
rc = i;
@@ -186,7 +186,7 @@ const char *jk_map_get_string(jk_map_t *m, const char *name, const char *def)
if (m && name) {
unsigned int i;
unsigned int hash;
- COMPUTE_KEY_HASH(name, hash)
+ COMPUTE_KEY_HASH(name, hash);
for (i = 0; i < m->size; i++) {
if (m->keys[i] == hash && strcmp(m->names[i], name) == 0) {
rc = m->values[i];
@@ -376,7 +376,7 @@ int jk_map_add(jk_map_t *m, const char *name, const void *value)
if (m && name) {
unsigned int hash;
- COMPUTE_KEY_HASH(name, hash)
+ COMPUTE_KEY_HASH(name, hash);
map_realloc(m);
if (m->size < m->capacity) {
@@ -398,7 +398,7 @@ int jk_map_put(jk_map_t *m, const char *name, const void *value, void **old)
if (m && name) {
unsigned int i;
unsigned int hash;
- COMPUTE_KEY_HASH(name, hash)
+ COMPUTE_KEY_HASH(name, hash);
for (i = 0; i < m->size; i++) {
if (m->keys[i] == hash && strcmp(m->names[i], name) == 0) {
break;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 11/20: Always check sizes
Posted by sc...@apache.org.
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 8e9fefef616da6417b5d835c8b24bce09441f395
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 14:19:37 2026 -0400
Always check sizes
---
native/common/jk_connect.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 292091c96..026d1e2e6 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1345,10 +1345,15 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
}
ps = strlen(buf);
- strncat(buf, pb, size - ps - 1);
- ps = strlen(buf);
- strncat(buf, " -> ", size - ps - 1);
- ps = strlen(buf);
+ if (ps < size) {
+ strncat(buf, pb, size - ps - 1);
+ ps = strlen(buf);
+ }
+
+ if (ps < size) {
+ strncat(buf, " -> ", size - ps - 1);
+ ps = strlen(buf);
+ }
sa = (struct sockaddr *)&rsaddr;
if (sa->sa_family == JK_INET) {
@@ -1365,9 +1370,12 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
#endif
else {
buf[ps] = '\0';
- snprintf(pb, sizeof(pb), "UnknownFamily");
+ snprintf(pb, sizeof(pb), "UnknownFamily");
+ }
+ ps = strlen(buf);
+ if (ps < size) {
+ strncat(buf, pb, size - ps - 1);
}
- strncat(buf, pb, size - strlen(buf) - 1);
return buf;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 02/20: Return existing pool on shrink-request
Posted by sc...@apache.org.
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 101ddeec5049d1127e1c74e6e2522e897b3d4daa
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 11:39:06 2026 -0400
Return existing pool on shrink-request
This API doesn't support shrinking, but the existing pool should be sufficient.
---
native/common/jk_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/native/common/jk_pool.c b/native/common/jk_pool.c
index e3da1bd45..5c8de05e9 100644
--- a/native/common/jk_pool.c
+++ b/native/common/jk_pool.c
@@ -104,7 +104,7 @@ void *jk_pool_realloc(jk_pool_t *p, size_t sz, const void *old, size_t old_sz)
char *rc;
if (!p || (sz < old_sz)) {
- return NULL;
+ return (void*)old;
}
if (!old)
return jk_pool_calloc(p, sz);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 10/20: Use correct blocking around ifdefs
Posted by sc...@apache.org.
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 7dfc5591305cbb3fc5a578f5faecd815ac036a1a
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 13:53:59 2026 -0400
Use correct blocking around ifdefs
---
native/common/jk_connect.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 812231b2c..292091c96 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1337,8 +1337,9 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&lsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ }
#endif
- } else {
+ else {
buf[0] = '\0';
snprintf(pb, sizeof(pb), "UnknownFamily");
}
@@ -1360,8 +1361,9 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&rsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ }
#endif
- } else {
+ else {
buf[ps] = '\0';
snprintf(pb, sizeof(pb), "UnknownFamily");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 13/20: Respect the return value from inet_ntop4/inet_ntop6
Posted by sc...@apache.org.
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 e6e066ed7cf4903bc52ce5d0e73464e7d389b587
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 14:33:59 2026 -0400
Respect the return value from inet_ntop4/inet_ntop6
---
native/common/jk_connect.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 120bc9551..6b9d85418 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1320,6 +1320,10 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr_storage lsaddr;
socklen_t salen;
+ if (size == 0) {
+ return buf;
+ }
+
salen = sizeof(lsaddr);
if (getsockname(sd, (struct sockaddr *)&lsaddr, &salen) == 0) {
salen = sizeof(rsaddr);
@@ -1330,14 +1334,22 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr *rsa = (struct sockaddr *)&rsaddr;
if (lsa->sa_family == JK_INET) {
struct sockaddr_in *insa = (struct sockaddr_in *)lsa;
- inet_ntop4((unsigned char *)&insa->sin_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
+ if (inet_ntop4((unsigned char *)&insa->sin_addr, buf, size) == NULL) {
+ buf[0] = '\0';
+ snprintf(pb, sizeof(pb), "InvalidAddr");
+ } else {
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
+ }
}
#if JK_HAVE_IPV6
else if (lsa->sa_family == JK_INET6) {
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)lsa;
- inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ if (inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size) == NULL) {
+ buf[0] = '\0';
+ snprintf(pb, sizeof(pb), "InvalidAddr");
+ } else {
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ }
}
#endif
else {
@@ -1358,14 +1370,22 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (rsa->sa_family == JK_INET) {
struct sockaddr_in *insa = (struct sockaddr_in *)rsa;
- inet_ntop4((unsigned char *)&insa->sin_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
+ if (inet_ntop4((unsigned char *)&insa->sin_addr, buf + ps, size - ps) == NULL) {
+ buf[ps] = '\0';
+ snprintf(pb, sizeof(pb), "InvalidAddr");
+ } else {
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
+ }
}
#if JK_HAVE_IPV6
else if (rsa->sa_family == JK_INET6) {
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)rsa;
- inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ if (inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps) == NULL) {
+ buf[ps] = '\0';
+ snprintf(pb, sizeof(pb), "InvalidAddr");
+ } else {
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ }
}
#endif
else {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 04/20: Use snprintf when printing port numbers
Posted by sc...@apache.org.
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 0d66c7de334162f50bdc7163600ada2d418966cc
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 11:56:20 2026 -0400
Use snprintf when printing port numbers
Also use the correct conversion for port numbers (n->h not h->n)
---
native/common/jk_connect.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 58172a9e7..839e530ab 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1329,13 +1329,13 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (lsaddr.sa_family == JK_INET) {
struct sockaddr_in *sa = (struct sockaddr_in *)&lsaddr;
inet_ntop4((unsigned char *)&sa->sin_addr, buf, size);
- sprintf(pb, ":%d", (unsigned int)htons(sa->sin_port));
+ snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin_port));
}
#if JK_HAVE_IPV6
else {
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&lsaddr;
inet_ntop6((unsigned char *)&sa->sin6_addr, buf, size);
- sprintf(pb, ":%d", (unsigned int)htons(sa->sin6_port));
+ snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin6_port));
}
#endif
ps = strlen(buf);
@@ -1346,13 +1346,13 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (rsaddr.sa_family == JK_INET) {
struct sockaddr_in *sa = (struct sockaddr_in *)&rsaddr;
inet_ntop4((unsigned char *)&sa->sin_addr, buf + ps, size - ps);
- sprintf(pb, ":%d", (unsigned int)htons(sa->sin_port));
+ snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin_port));
}
#if JK_HAVE_IPV6
else {
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&rsaddr;
inet_ntop6((unsigned char *)&sa->sin6_addr, buf + ps, size - ps);
- sprintf(pb, ":%d", (unsigned int)htons(sa->sin6_port));
+ snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin6_port));
}
#endif
strncat(buf, pb, size - strlen(buf) - 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 15/20: Improve performance
Posted by sc...@apache.org.
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 53506d4b86dc6b8a9c755adf63b5ea73bcd5f4d7
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 15:46:18 2026 -0400
Improve performance
Don't bother converting from double -> string -> double
Use strtod instead of atof to get error handling
---
native/common/jk_map.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/native/common/jk_map.c b/native/common/jk_map.c
index 8c6de4240..04eb325a4 100644
--- a/native/common/jk_map.c
+++ b/native/common/jk_map.c
@@ -230,13 +230,22 @@ int jk_map_get_int(jk_map_t *m, const char *name, int def)
double jk_map_get_double(jk_map_t *m, const char *name, double def)
{
- char buf[100];
- const char *rc;
+ const char *rc = jk_map_get_string(m, name, NULL);
+ char *end;
+ double d;
- sprintf(buf, "%f", def);
- rc = jk_map_get_string(m, name, buf);
+ if (rc == NULL) {
+ return def;
+ }
+
+ errno = 0;
+ d = strtod(rc, &end);
+
+ if (end == rc || errno == ERANGE) {
+ return def;
+ }
- return atof(rc);
+ return d;
}
int jk_map_get_bool(jk_map_t *m, const char *name, int def)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 19/20: Avoid unlikely underflow
Posted by sc...@apache.org.
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 1c5b840ce09c9161327f919cd3e63a5ffbea51a1
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 17:41:04 2026 -0400
Avoid unlikely underflow
---
native/common/jk_sockbuf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/native/common/jk_sockbuf.c b/native/common/jk_sockbuf.c
index 107eb09be..32c53931a 100644
--- a/native/common/jk_sockbuf.c
+++ b/native/common/jk_sockbuf.c
@@ -40,7 +40,11 @@ int jk_sb_open(jk_sockbuf_t *sb, jk_sock_t sd)
int jk_sb_write(jk_sockbuf_t *sb, const void *buf, unsigned sz)
{
if (sb && buf && sz) {
- if ((SOCKBUF_SIZE - sb->end) >= sz) {
+ if (sb->end >= SOCKBUF_SIZE) {
+ return JK_FALSE;
+ }
+
+ if (sz <= SOCKBUF_SIZE - sb->end) {
memcpy(sb->buf + sb->end, buf, sz);
sb->end += sz;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 18/20: Add overrun protection
Posted by sc...@apache.org.
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 21987720da59ea06b703c5d304c5b34824371423
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 16:59:02 2026 -0400
Add overrun protection
Reduce unnecessary safety margin
---
native/common/jk_ajp12_worker.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/native/common/jk_ajp12_worker.c b/native/common/jk_ajp12_worker.c
index d9d860ba5..40f45fbe3 100644
--- a/native/common/jk_ajp12_worker.c
+++ b/native/common/jk_ajp12_worker.c
@@ -390,8 +390,8 @@ static int ajpv12_mark(ajp12_endpoint_t * p, unsigned char type)
static int ajpv12_sendint(ajp12_endpoint_t * p, int d)
{
- char buf[20];
- sprintf(buf, "%d", d);
+ char buf[16];
+ snprintf(buf, sizeof(buf), "%d", d);
return ajpv12_sendstring(p, buf);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 03/20: Avoid overflow on alignment adjustment
Posted by sc...@apache.org.
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 197c7baf308002b327abbc8f885ede8aa94351cb
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 11:43:09 2026 -0400
Avoid overflow on alignment adjustment
---
native/common/jk_pool.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/native/common/jk_pool.c b/native/common/jk_pool.c
index 5c8de05e9..9adbfa761 100644
--- a/native/common/jk_pool.c
+++ b/native/common/jk_pool.c
@@ -64,6 +64,11 @@ void *jk_pool_alloc(jk_pool_t *p, size_t size)
if (size == 0)
return NULL;
+
+ if (sz > SIZE_MAX - JK_ALIGN_DEFAULT(1)) {
+ return NULL;
+ }
+
size = JK_ALIGN_DEFAULT(size);
if ((p->size - p->pos) >= size) {
rc = &(p->buf[p->pos]);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 20/20: Fix a few issues in jk_sb_send
Posted by sc...@apache.org.
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 ed383e12ca21035f42c4bcb8cb128f8ee63363ae
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 18:18:32 2026 -0400
Fix a few issues in jk_sb_send
Tolerate situations where send() does not send the complete message on the first try
Writing a zero-length buffer is always successful
---
native/common/jk_sockbuf.c | 78 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 61 insertions(+), 17 deletions(-)
diff --git a/native/common/jk_sockbuf.c b/native/common/jk_sockbuf.c
index 32c53931a..b82d78fdb 100644
--- a/native/common/jk_sockbuf.c
+++ b/native/common/jk_sockbuf.c
@@ -37,33 +37,77 @@ int jk_sb_open(jk_sockbuf_t *sb, jk_sock_t sd)
return JK_FALSE;
}
-int jk_sb_write(jk_sockbuf_t *sb, const void *buf, unsigned sz)
+/* send all data in buf (up to len) to the file descriptor */
+static int jk_sb_send_all(int sd, const void *buf, size_t len)
{
- if (sb && buf && sz) {
- if (sb->end >= SOCKBUF_SIZE) {
- return JK_FALSE;
- }
+ size_t total = 0;
+
+ if (len == 0) {
+ return JK_TRUE;
+ }
- if (sz <= SOCKBUF_SIZE - sb->end) {
- memcpy(sb->buf + sb->end, buf, sz);
- sb->end += sz;
+ while (total < len) {
+ ssize_t n = send(sd,
+ (const char *)buf + total,
+ len - total,
+ 0);
+
+ if (n > 0) {
+ total += (size_t)n;
+ continue;
}
- else {
- if (!jk_sb_flush(sb)) {
- return JK_FALSE;
- }
- if (sz > SOCKBUF_SIZE) {
- return (send(sb->sd, (char *)buf, sz, 0) == (int)sz);
+
+ if (n == -1) {
+ if (errno == EINTR) {
+ continue; // interrupted, retry
}
- memcpy(sb->buf + sb->end, buf, sz);
- sb->end += sz;
+ // Any other error is fatal for this write
+ return JK_FALSE;
}
+ // n == 0: treat as connection closed or invalid state
+ return JK_FALSE;
+ }
+
+ return JK_TRUE;
+}
+
+int jk_sb_write(jk_sockbuf_t *sb, const void *buf, unsigned sz)
+{
+ if (!sb || !buf) {
+ return JK_FALSE;
+ }
+ if (sz == 0) {
return JK_TRUE;
}
- return JK_FALSE;
+ if (sb->end >= SOCKBUF_SIZE) {
+ return JK_FALSE;
+ }
+
+ if (sz <= SOCKBUF_SIZE - sb->end) {
+ memcpy(sb->buf + sb->end, buf, sz);
+ sb->end += sz;
+
+ return JK_TRUE;
+ }
+
+ /* write cannot fit into remaining buffer, so flush */
+ if (!jk_sb_flush(sb)) {
+ return JK_FALSE;
+ }
+
+ /* don't buffer writes that will never fit */
+ if (sz > SOCKBUF_SIZE) {
+ return jk_sb_send_all(sb->sd, buf, sz);
+ }
+
+ /* buffer small write-after-flush */
+ memcpy(sb->buf + sb->end, buf, sz);
+ sb->end += sz;
+
+ return JK_TRUE;
}
int jk_sb_flush(jk_sockbuf_t *sb)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 16/20: Improve performance
Posted by sc...@apache.org.
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 83c4ef518028d8d43f413422cc8f2c1314b0de5a
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 16:13:55 2026 -0400
Improve performance
Don't bother converting from int -> string -> int
Use strtol instead of atof to get error handling
---
native/common/jk_map.c | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/native/common/jk_map.c b/native/common/jk_map.c
index 04eb325a4..116efd868 100644
--- a/native/common/jk_map.c
+++ b/native/common/jk_map.c
@@ -201,31 +201,35 @@ const char *jk_map_get_string(jk_map_t *m, const char *name, const char *def)
int jk_map_get_int(jk_map_t *m, const char *name, int def)
{
- char buf[100];
- const char *rc;
- size_t len;
- int int_res;
+ const char *rc = jk_map_get_string(m, name, NULL);
+ char *end;
+ long l;
+ long multit = 1;
- sprintf(buf, "%d", def);
- rc = jk_map_get_string(m, name, buf);
+ if (rc == NULL) {
+ return def;
+ }
- len = strlen(rc);
- if (len) {
- const char *lastchar = &rc[0] + len - 1;
- int multit = 1;
- if ('m' == *lastchar || 'M' == *lastchar) {
- multit = 1024 * 1024;
- }
- else if ('k' == *lastchar || 'K' == *lastchar) {
- multit = 1024;
- }
- /* Safe because atoi() will stop at any non-numeric lastchar */
- int_res = atoi(rc) * multit;
+ errno = 0;
+
+ l = strtol(rc, &end, 10);
+
+ if (end == rc || errno == ERANGE) {
+ return def;
}
- else
- int_res = def;
- return int_res;
+ char c = *end;
+ if (c == 'm' || c == 'M') {
+ multit = 1024 * 1024;
+ } else if (c == 'k' || c == 'K') {
+ multit = 1024;
+ }
+
+ if (l > INT_MAX / multit || l < INT_MIN / multit) {
+ return def;
+ }
+
+ return (int)(l * multit);
}
double jk_map_get_double(jk_map_t *m, const char *name, double def)
@@ -239,6 +243,7 @@ double jk_map_get_double(jk_map_t *m, const char *name, double def)
}
errno = 0;
+
d = strtod(rc, &end);
if (end == rc || errno == ERANGE) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 07/20: Don't assume IPv6 when not IPv4
Posted by sc...@apache.org.
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 412cb1e32c0db661ce7d18e8142d41165b5b0452
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 12:39:48 2026 -0400
Don't assume IPv6 when not IPv4
---
native/common/jk_connect.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 5477be83b..9c0f653cd 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1333,10 +1333,12 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
- else {
+ else if (sa->sa_family == JK_INET6) {
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&lsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ } else {
+ snprintf(pb, sizeof(pb), "UnknownFamily");
}
#endif
ps = strlen(buf);
@@ -1352,10 +1354,12 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
- else {
+ else if (sa->sa_family == JK_INET6) {
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&rsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+ } else {
+ snprintf(pb, sizeof(pb), "UnknownFamily");
}
#endif
strncat(buf, pb, size - strlen(buf) - 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 01/20: Always use 'size' passed-in from the caller
Posted by sc...@apache.org.
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 <ch...@christopherschultz.net>
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 05/20: Use correct conversion for unsigned int
Posted by sc...@apache.org.
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 3cc048f50de2eb1baa1e772793faa19b58f9776f
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 12:03:15 2026 -0400
Use correct conversion for unsigned int
Remove unnecessary cast
---
native/common/jk_connect.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 839e530ab..0bd124c26 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1329,13 +1329,13 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (lsaddr.sa_family == JK_INET) {
struct sockaddr_in *sa = (struct sockaddr_in *)&lsaddr;
inet_ntop4((unsigned char *)&sa->sin_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin_port));
+ snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin_port));
}
#if JK_HAVE_IPV6
else {
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&lsaddr;
inet_ntop6((unsigned char *)&sa->sin6_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin6_port));
+ snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin6_port));
}
#endif
ps = strlen(buf);
@@ -1346,13 +1346,13 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (rsaddr.sa_family == JK_INET) {
struct sockaddr_in *sa = (struct sockaddr_in *)&rsaddr;
inet_ntop4((unsigned char *)&sa->sin_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin_port));
+ snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin_port));
}
#if JK_HAVE_IPV6
else {
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&rsaddr;
inet_ntop6((unsigned char *)&sa->sin6_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%d", (unsigned int)ntohs(sa->sin6_port));
+ snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin6_port));
}
#endif
strncat(buf, pb, size - strlen(buf) - 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 09/20: Move the else outside of the ifdef
Posted by sc...@apache.org.
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 84506485f78cd35739387aa3bd5b2d463bc1ce5d
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 13:45:57 2026 -0400
Move the else outside of the ifdef
Expand the buffer to be able to store the unknown family note.
---
native/common/jk_connect.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 9c0f653cd..812231b2c 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1324,7 +1324,7 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (getsockname(sd, &lsaddr, &salen) == 0) {
salen = sizeof(rsaddr);
if (getpeername(sd, &rsaddr, &salen) == 0) {
- char pb[8];
+ char pb[16];
size_t ps;
struct sockaddr *sa = (struct sockaddr *)&lsaddr;
if (sa->sa_family == JK_INET) {
@@ -1337,10 +1337,12 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&lsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+#endif
} else {
+ buf[0] = '\0';
snprintf(pb, sizeof(pb), "UnknownFamily");
}
-#endif
+
ps = strlen(buf);
strncat(buf, pb, size - ps - 1);
ps = strlen(buf);
@@ -1358,10 +1360,11 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&rsaddr;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
+#endif
} else {
+ buf[ps] = '\0';
snprintf(pb, sizeof(pb), "UnknownFamily");
}
-#endif
strncat(buf, pb, size - strlen(buf) - 1);
return buf;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 06/20: Use sockaddr_storage to ensure we have enough space for IPv6
Posted by sc...@apache.org.
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 7966dd1e427d953d7391b57c28aba310d37f8696
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 12:29:29 2026 -0400
Use sockaddr_storage to ensure we have enough space for IPv6
---
native/common/jk_connect.c | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 0bd124c26..5477be83b 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1316,26 +1316,27 @@ char *jk_dump_hinfo(jk_sockaddr_t *saddr, char *buf, size_t size)
char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
{
- struct sockaddr rsaddr;
- struct sockaddr lsaddr;
+ struct sockaddr_storage rsaddr;
+ struct sockaddr_storage lsaddr;
socklen_t salen;
- salen = sizeof(struct sockaddr);
+ salen = sizeof(lsaddr);
if (getsockname(sd, &lsaddr, &salen) == 0) {
- salen = sizeof(struct sockaddr);
+ salen = sizeof(rsaddr);
if (getpeername(sd, &rsaddr, &salen) == 0) {
char pb[8];
size_t ps;
- if (lsaddr.sa_family == JK_INET) {
- struct sockaddr_in *sa = (struct sockaddr_in *)&lsaddr;
- inet_ntop4((unsigned char *)&sa->sin_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin_port));
+ struct sockaddr *sa = (struct sockaddr *)&lsaddr;
+ if (sa->sa_family == JK_INET) {
+ struct sockaddr_in *insa = (struct sockaddr_in *)&lsaddr;
+ inet_ntop4((unsigned char *)&insa->sin_addr, buf, size);
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
else {
- struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&lsaddr;
- inet_ntop6((unsigned char *)&sa->sin6_addr, buf, size);
- snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin6_port));
+ struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&lsaddr;
+ inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
}
#endif
ps = strlen(buf);
@@ -1343,16 +1344,18 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
ps = strlen(buf);
strncat(buf, " -> ", size - ps - 1);
ps = strlen(buf);
- if (rsaddr.sa_family == JK_INET) {
- struct sockaddr_in *sa = (struct sockaddr_in *)&rsaddr;
- inet_ntop4((unsigned char *)&sa->sin_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin_port));
+
+ sa = (struct sockaddr *)&rsaddr;
+ if (sa->sa_family == JK_INET) {
+ struct sockaddr_in *insa = (struct sockaddr_in *)&rsaddr;
+ inet_ntop4((unsigned char *)&insa->sin_addr, buf + ps, size - ps);
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
else {
- struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&rsaddr;
- inet_ntop6((unsigned char *)&sa->sin6_addr, buf + ps, size - ps);
- snprintf(pb, sizeof(pb), ":%u", ntohs(sa->sin6_port));
+ struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&rsaddr;
+ inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
+ snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
}
#endif
strncat(buf, pb, size - strlen(buf) - 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 12/20: Slight cleanup
Posted by sc...@apache.org.
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 6d69b5485667fd23c987c9f3948c4d187a1897dc
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 14:24:33 2026 -0400
Slight cleanup
---
native/common/jk_connect.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 026d1e2e6..120bc9551 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1321,20 +1321,21 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
socklen_t salen;
salen = sizeof(lsaddr);
- if (getsockname(sd, &lsaddr, &salen) == 0) {
+ if (getsockname(sd, (struct sockaddr *)&lsaddr, &salen) == 0) {
salen = sizeof(rsaddr);
- if (getpeername(sd, &rsaddr, &salen) == 0) {
+ if (getpeername(sd, (struct sockaddr *)&rsaddr, &salen) == 0) {
char pb[16];
size_t ps;
- struct sockaddr *sa = (struct sockaddr *)&lsaddr;
- if (sa->sa_family == JK_INET) {
- struct sockaddr_in *insa = (struct sockaddr_in *)&lsaddr;
+ struct sockaddr *lsa = (struct sockaddr *)&lsaddr;
+ struct sockaddr *rsa = (struct sockaddr *)&rsaddr;
+ if (lsa->sa_family == JK_INET) {
+ struct sockaddr_in *insa = (struct sockaddr_in *)lsa;
inet_ntop4((unsigned char *)&insa->sin_addr, buf, size);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
- else if (sa->sa_family == JK_INET6) {
- struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&lsaddr;
+ else if (lsa->sa_family == JK_INET6) {
+ struct sockaddr_in6 *insa = (struct sockaddr_in6 *)lsa;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf, size);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
}
@@ -1355,15 +1356,14 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
ps = strlen(buf);
}
- sa = (struct sockaddr *)&rsaddr;
- if (sa->sa_family == JK_INET) {
- struct sockaddr_in *insa = (struct sockaddr_in *)&rsaddr;
+ if (rsa->sa_family == JK_INET) {
+ struct sockaddr_in *insa = (struct sockaddr_in *)rsa;
inet_ntop4((unsigned char *)&insa->sin_addr, buf + ps, size - ps);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
}
#if JK_HAVE_IPV6
- else if (sa->sa_family == JK_INET6) {
- struct sockaddr_in6 *insa = (struct sockaddr_in6 *)&rsaddr;
+ else if (rsa->sa_family == JK_INET6) {
+ struct sockaddr_in6 *insa = (struct sockaddr_in6 *)rsa;
inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps);
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat-connectors) 14/20: Remove unnecessary null-terminators
Posted by sc...@apache.org.
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 7b57bf6a232522bfe68f99936ead942175fed51d
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Jun 8 14:40:09 2026 -0400
Remove unnecessary null-terminators
---
native/common/jk_connect.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/native/common/jk_connect.c b/native/common/jk_connect.c
index 6b9d85418..812ebf1aa 100644
--- a/native/common/jk_connect.c
+++ b/native/common/jk_connect.c
@@ -1371,7 +1371,6 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
if (rsa->sa_family == JK_INET) {
struct sockaddr_in *insa = (struct sockaddr_in *)rsa;
if (inet_ntop4((unsigned char *)&insa->sin_addr, buf + ps, size - ps) == NULL) {
- buf[ps] = '\0';
snprintf(pb, sizeof(pb), "InvalidAddr");
} else {
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin_port));
@@ -1381,7 +1380,6 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
else if (rsa->sa_family == JK_INET6) {
struct sockaddr_in6 *insa = (struct sockaddr_in6 *)rsa;
if (inet_ntop6((unsigned char *)&insa->sin6_addr, buf + ps, size - ps) == NULL) {
- buf[ps] = '\0';
snprintf(pb, sizeof(pb), "InvalidAddr");
} else {
snprintf(pb, sizeof(pb), ":%u", ntohs(insa->sin6_port));
@@ -1389,7 +1387,6 @@ char *jk_dump_sinfo(jk_sock_t sd, char *buf, size_t size)
}
#endif
else {
- buf[ps] = '\0';
snprintf(pb, sizeof(pb), "UnknownFamily");
}
ps = strlen(buf);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org