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

Reply via email to