From f671c004df59842d321e8f549201797f72c1130d Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Fri, 19 May 2023 19:47:16 +0800 Subject: [PATCH] netlib: set addr.sin_zero to 0 in netlib_set_ipv4dnsaddr In dns_add_nameserver, the dns_check_nameserver is comparing addresses with addrlen = sizeof(struct sockaddr_in) for IPv4 addresses, so the trailing sin_zero field should be 0, otherwise it may fail to figure out same nameserver address. Signed-off-by: Zhe Weng --- netutils/netlib/netlib_setipv4dnsaddr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/netutils/netlib/netlib_setipv4dnsaddr.c b/netutils/netlib/netlib_setipv4dnsaddr.c index 4d4e82404..f95af1c9d 100644 --- a/netutils/netlib/netlib_setipv4dnsaddr.c +++ b/netutils/netlib/netlib_setipv4dnsaddr.c @@ -68,6 +68,7 @@ int netlib_set_ipv4dnsaddr(FAR const struct in_addr *inaddr) addr.sin_family = AF_INET; addr.sin_port = 0; memcpy(&addr.sin_addr, inaddr, sizeof(struct in_addr)); + bzero(&addr.sin_zero, sizeof(addr.sin_zero)); ret = dns_add_nameserver((FAR const struct sockaddr *)&addr, sizeof(struct sockaddr_in));