ccx-utils

Miscellaneous utilities written in C
git clone https://ccx.te2000.cz/git/ccx-utils
Log | Files | Refs

commit 20e3aaaf3c753fd20d6f9df92e950d3e0cb18f53
parent 9775572b7114d745ab10714a7a84e3e92ebed749
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Sun,  3 Nov 2024 07:21:57 +0000

Fix amount of storage provided to getsockname()

Diffstat:
Msrc/ucspi-socksserver-connected.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ucspi-socksserver-connected.c b/src/ucspi-socksserver-connected.c @@ -117,13 +117,13 @@ int main (int argc, char const *const *argv) if (strcmp(env_socks_version, "5") == 0) { - struct sockaddr local_addr; + struct sockaddr_storage local_addr; socklen_t addrlen = sizeof(local_addr); - if(getsockname(6, &local_addr, &addrlen) != 0) { + if(getsockname(6, (struct sockaddr *)&local_addr, &addrlen) != 0) { strerr_diefu1sys(111, "getsockname(6, ...)"); } assert(addrlen <= sizeof(local_addr)); - switch(local_addr.sa_family) { + switch(local_addr.ss_family) { case AF_INET: struct sockaddr_in *in_addr = (struct sockaddr_in *)&local_addr; socks5_reply_ok(SOCKS5_ADDR_TYPE_IP4, &in_addr->sin_addr, in_addr->sin_port);