socks4_connect(): Fix the dstsize passed to strlcpy() in case of socks4a
authorFabian Keil <fk@fabiankeil.de>
Thu, 11 Sep 2025 11:54:17 +0000 (13:54 +0200)
committerFabian Keil <fk@fabiankeil.de>
Thu, 9 Oct 2025 09:51:07 +0000 (11:51 +0200)
Previously we would substract sizeof(struct socks_op) twice
as it's already part of csiz. While this was wrong it didn't
cause any actual problems as the buffer size is so large that
it didn't matter.

Reported by: Joshua Rogers

gateway.c

index 7b0412d..fc71291 100644 (file)
--- a/gateway.c
+++ b/gateway.c
@@ -875,7 +875,7 @@ static jb_socket socks4_connect(const struct forward_spec *fwd,
          }
          else
          {
-            strlcpy(buf + csiz, target_host, sizeof(buf) - sizeof(struct socks_op) - csiz);
+            strlcpy(buf + csiz, target_host, sizeof(buf) - csiz);
             /*
              * What we forward to the socks4a server should have the
              * size of socks_op, plus the length of the userid plus