fix omission to reset socklen parameter for accept()

since accept() uses the socklen parameter as in/out, after processing
an IPv4 the socklen fed to it waiting for the next client was only
the length of sockaddr_in, so if a connection from an IPv6 came in
the client sockaddr was only partially filled in.
this caused wrongly printed ipv6 addresses in log, and failure to
match them correctly against the acl.

closes #495
This commit is contained in:
rofl0r 2023-06-07 18:57:05 +00:00
parent d7c20e663f
commit 2935519eb7

View File

@ -81,7 +81,7 @@ void child_main_loop (void)
int connfd; int connfd;
union sockaddr_union cliaddr_storage; union sockaddr_union cliaddr_storage;
struct sockaddr *cliaddr = (void*) &cliaddr_storage; struct sockaddr *cliaddr = (void*) &cliaddr_storage;
socklen_t clilen = sizeof(cliaddr_storage); socklen_t clilen;
int nfds = sblist_getsize(listen_fds); int nfds = sblist_getsize(listen_fds);
pollfd_struct *fds = safecalloc(nfds, sizeof *fds); pollfd_struct *fds = safecalloc(nfds, sizeof *fds);
ssize_t i; ssize_t i;
@ -167,6 +167,7 @@ void child_main_loop (void)
* Continue handling this connection. * Continue handling this connection.
*/ */
clilen = sizeof(cliaddr_storage);
connfd = accept (listenfd, cliaddr, &clilen); connfd = accept (listenfd, cliaddr, &clilen);