From 3883a51969907f604b8e213cb50fb5b8c352c04d Mon Sep 17 00:00:00 2001 From: Derrick Lyndon Pallas Date: Fri, 9 Oct 2026 23:36:25 -0700 Subject: [PATCH] Fix: wrong sasize in sockgetchar/sockrecvfrom On receive, the struct sockaddr is zeroed and does not have an address family until recvfrom fills it in. SASIZE assumes that if there is no address family, it is INET. This means that for IPv6 UDP sockets, the sockaddr is truncated and the reply is forwarded to the wrong address. Instead, use sizeof(PROXYSOCKADDRTYPE). --- src/sockgetchar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sockgetchar.c b/src/sockgetchar.c index 2e0ae0e..076cb51 100644 --- a/src/sockgetchar.c +++ b/src/sockgetchar.c @@ -63,7 +63,7 @@ int sockrecvfrom(struct clientparam *param, SOCKET sock, struct sockaddr * sin, if(conf.timetoexit) return EOF; res = param?param->srv->so._poll(param->sostate, &fds, 1, to):so._poll(so.state, &fds, 1, to); if (res<1) return 0; - sasize = SASIZE(sin); + sasize = sizeof(PROXYSOCKADDRTYPE); do { res = param?param->srv->so._recvfrom(param->sostate, sock, (char *)buf, bufsize, 0, (struct sockaddr *)sin, &sasize):so._recvfrom(so.state, sock, (char *)buf, bufsize, 0, (struct sockaddr *)sin, &sasize); } while (res < 0 && (errno == EAGAIN || errno == EINTR));