From bf7ad258d687fdafff5a370a25f15828dd4b16e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Tue, 7 Jan 2025 01:24:10 -0500 Subject: [PATCH] Fix TLS short send issue. On JS TLS sockets, sends over 16384 bytes would be truncated to the next multiple of 8192 higher than half the buffer length. This was triggered because we send chunks of 8192 bytes at a time, and decrement the length each time through the loop. We return "success" when the total sent so far is higher than the length remaining. Fixes bug reported in #Synchronet by Accession. --- src/sbbs3/js_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbbs3/js_socket.c b/src/sbbs3/js_socket.c index cf264a3b7d..3a45084711 100644 --- a/src/sbbs3/js_socket.c +++ b/src/sbbs3/js_socket.c @@ -372,7 +372,7 @@ static ptrdiff_t js_socket_sendsocket(js_socket_private_t *p, const void *msg, s if(p->nonblocking) return copied; total += copied; - if(total >= (ptrdiff_t)len) + if(copied >= (ptrdiff_t)len) return total; do_CryptFlush(p); len -= copied; -- GitLab