Skip to content

Commit

Permalink
Update struct type for sock_addr
Browse files Browse the repository at this point in the history
This allows for expanded storage to handle IPV6 addresses.

Signed-off-by: jomillerOpen <[email protected]>
  • Loading branch information
jomillerOpen committed Sep 19, 2024
1 parent 41b90b7 commit 399b82d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/flb_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1758,10 +1758,16 @@ int flb_net_bind_udp(flb_sockfd_t fd, const struct sockaddr *addr,
flb_sockfd_t flb_net_accept(flb_sockfd_t server_fd)
{
flb_sockfd_t remote_fd;
struct sockaddr sock_addr;
socklen_t socket_size = sizeof(struct sockaddr);

// return accept(server_fd, &sock_addr, &socket_size);
struct sockaddr_storage sock_addr = { 0 };
socklen_t socket_size = sizeof(sock_addr);

/*
* sock_addr used to be a sockaddr struct, but this was too
* small of a structure to handle IPV6 addresses (#9053).
* This would cause accept() to not accept the connection (with no error),
* and a loop would occur continually trying to accept the connection.
* The sockaddr_storage can handle both IPV4 and IPV6.
*/

#ifdef FLB_HAVE_ACCEPT4
remote_fd = accept4(server_fd, &sock_addr, &socket_size,
Expand Down

0 comments on commit 399b82d

Please sign in to comment.