Skip to content

Commit 6654681

Browse files
jomillerOpenedsiper
authored andcommitted
network: Update struct type for sock_addr
This allows for expanded storage to handle IPV6 addresses. Signed-off-by: jomillerOpen <[email protected]>
1 parent ff584f5 commit 6654681

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/flb_network.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,10 +1807,16 @@ int flb_net_bind_udp(flb_sockfd_t fd, const struct sockaddr *addr,
18071807
flb_sockfd_t flb_net_accept(flb_sockfd_t server_fd)
18081808
{
18091809
flb_sockfd_t remote_fd;
1810-
struct sockaddr sock_addr;
1811-
socklen_t socket_size = sizeof(struct sockaddr);
1812-
1813-
// return accept(server_fd, &sock_addr, &socket_size);
1810+
struct sockaddr_storage sock_addr = { 0 };
1811+
socklen_t socket_size = sizeof(sock_addr);
1812+
1813+
/*
1814+
* sock_addr used to be a sockaddr struct, but this was too
1815+
* small of a structure to handle IPV6 addresses (#9053).
1816+
* This would cause accept() to not accept the connection (with no error),
1817+
* and a loop would occur continually trying to accept the connection.
1818+
* The sockaddr_storage can handle both IPV4 and IPV6.
1819+
*/
18141820

18151821
#ifdef FLB_HAVE_ACCEPT4
18161822
remote_fd = accept4(server_fd, &sock_addr, &socket_size,

0 commit comments

Comments
 (0)