mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
Fixed using wrong sockaddr type in lwip_getaddrinfo when IPv6 is enabled
This commit is contained in:
parent
52a4ca99a8
commit
cca758d332
@ -346,7 +346,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
}
|
||||
}
|
||||
|
||||
total_size = sizeof(struct addrinfo) + sizeof(struct sockaddr_in);
|
||||
total_size = sizeof(struct addrinfo) + sizeof(struct sockaddr_storage);
|
||||
if (nodename != NULL) {
|
||||
namelen = strlen(nodename);
|
||||
if (namelen > DNS_MAX_NAME_LENGTH) {
|
||||
@ -395,11 +395,11 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
}
|
||||
if (nodename != NULL) {
|
||||
/* copy nodename to canonname if specified */
|
||||
ai->ai_canonname = ((char*)ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
|
||||
ai->ai_canonname = ((char*)ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_storage));
|
||||
MEMCPY(ai->ai_canonname, nodename, namelen);
|
||||
ai->ai_canonname[namelen] = 0;
|
||||
}
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_storage);
|
||||
ai->ai_addr = (struct sockaddr*)sa;
|
||||
|
||||
*res = ai;
|
||||
|
@ -246,7 +246,9 @@ union sockaddr_aligned {
|
||||
#if LWIP_IPV6
|
||||
struct sockaddr_in6 sin6;
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_IPV4
|
||||
struct sockaddr_in sin;
|
||||
#endif /* LWIP_IPV4 */
|
||||
};
|
||||
|
||||
#if LWIP_IGMP
|
||||
|
@ -59,6 +59,7 @@ typedef u8_t sa_family_t;
|
||||
typedef u16_t in_port_t;
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4
|
||||
/* members are in network byte order */
|
||||
struct sockaddr_in {
|
||||
u8_t sin_len;
|
||||
@ -68,6 +69,7 @@ struct sockaddr_in {
|
||||
#define SIN_ZERO_LEN 8
|
||||
char sin_zero[SIN_ZERO_LEN];
|
||||
};
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
struct sockaddr_in6 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user