Skip to content

Commit

Permalink
Set member sockaddr_in::sin_len if it exists.
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Carroll <[email protected]>
  • Loading branch information
tomc797 committed Jun 24, 2023
1 parent 45d71d4 commit 8f876f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/zitilib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,12 +1287,18 @@ int Ziti_resolve(const char *host, const char *port, const struct addrinfo *hint
case AF_INET:
case AF_UNSPEC:
salen = sizeof addr->in4;
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
addr->in4.sin_len = salen;
#endif /* HAVE_SOCKADDR_IN_SIN_LEN */
addr->in4.sin_family = AF_INET;
addr->in4.sin_port = htons(portnum);
addr->in4.sin_addr.s_addr = INADDR_LOOPBACK;
break;
case AF_INET6:
salen = sizeof addr->in6;
#ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
addr->in6.sin6_len = salen;
#endif /* HAVE_SOCKADDR_IN6_SIN6_LEN */
addr->in6.sin6_family = AF_INET6;
addr->in6.sin6_port = htons(portnum);
addr->in6.sin6_addr = in6addr_loopback;
Expand Down Expand Up @@ -1362,6 +1368,9 @@ int Ziti_resolve(const char *host, const char *port, const struct addrinfo *hint
if (err != 0)
goto error;

#ifdef HAVE_SOCKADDR_IN_SIN_LEN
addr->in4.sin_len = sizeof addr->in4;
#endif /* HAVE_SOCKADDR_IN_SIN_LEN */
addr->in4.sin_family = AF_INET;
addr->in4.sin_port = htons(portnum);
addr->in4.sin_addr.s_addr = (in_addr_t)(uintptr_t)f->result;
Expand Down

0 comments on commit 8f876f9

Please sign in to comment.