This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new f671c004d netlib: set addr.sin_zero to 0 in netlib_set_ipv4dnsaddr
f671c004d is described below
commit f671c004df59842d321e8f549201797f72c1130d
Author: Zhe Weng <[email protected]>
AuthorDate: Fri May 19 19:47:16 2023 +0800
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 <[email protected]>
---
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));