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 <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to