Skip to content

Commit

Permalink
Fixed netdb.c when LWIP_SOCKET_HAVE_SA_LEN == 0
Browse files Browse the repository at this point in the history
Fields sin6_len and sin_len are always used in the file but not all implementations of sockaddr_in or sockaddr_in6 have this fields (including Linux implementation).
Added #if-check to avoid compilation errors in such cases.
  • Loading branch information
RUSLoker authored and goldsimon committed Feb 19, 2024
1 parent 7c494b3 commit 93821fc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/netdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
sa6->sin6_family = AF_INET6;
#if LWIP_SOCKET_HAVE_SA_LEN
sa6->sin6_len = sizeof(struct sockaddr_in6);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa6->sin6_port = lwip_htons((u16_t)port_nr);
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
ai->ai_family = AF_INET6;
Expand All @@ -394,7 +396,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
sa4->sin_family = AF_INET;
#if LWIP_SOCKET_HAVE_SA_LEN
sa4->sin_len = sizeof(struct sockaddr_in);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa4->sin_port = lwip_htons((u16_t)port_nr);
ai->ai_family = AF_INET;
#endif /* LWIP_IPV4 */
Expand Down

0 comments on commit 93821fc

Please sign in to comment.