summaryrefslogtreecommitdiffstats
path: root/dirmngr/dns.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2018-06-15 03:38:22 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2018-06-15 03:38:22 +0200
commit1c0b6681e4f322b88ac35d1f21c03d3cfc35fc23 (patch)
tree5c9edf1c00afd76720a98d35fad84b8b4fb40baf /dirmngr/dns.c
parentlibdns: Sync to upstream. (diff)
downloadgnupg2-1c0b6681e4f322b88ac35d1f21c03d3cfc35fc23.tar.xz
gnupg2-1c0b6681e4f322b88ac35d1f21c03d3cfc35fc23.zip
libdns: Clear struct sockaddr_storage by zero.
* dirmngr/dns.c (dns_resconf_pton): Clear SS. (dns_resconf_setiface): Clear ->IFACE. (dns_hints_root, send_query): Clear SS. -- POSIX requires clear the structure of struct sockaddr_in6. On macOS, in some case like bind, it is better to clear even for struct sockaddr_in. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'dirmngr/dns.c')
-rw-r--r--dirmngr/dns.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/dirmngr/dns.c b/dirmngr/dns.c
index 13ef4b8fd..178070a90 100644
--- a/dirmngr/dns.c
+++ b/dirmngr/dns.c
@@ -5549,6 +5549,7 @@ int dns_resconf_pton(struct sockaddr_storage *ss, const char *src) {
unsigned short port = 0;
int ch, af = AF_INET, error;
+ memset(ss, 0, sizeof *ss);
while ((ch = *src++)) {
switch (ch) {
case ' ':
@@ -6311,6 +6312,7 @@ int dns_resconf_setiface(struct dns_resolv_conf *resconf, const char *addr, unsi
int af = (strchr(addr, ':'))? AF_INET6 : AF_INET;
int error;
+ memset(&resconf->iface, 0, sizeof (struct sockaddr_storage));
if ((error = dns_pton(af, addr, dns_sa_addr(af, &resconf->iface, NULL))))
return error;
@@ -6622,6 +6624,7 @@ struct dns_hints *dns_hints_root(struct dns_resolv_conf *resconf, int *error_) {
for (i = 0; i < lengthof(root_hints); i++) {
af = root_hints[i].af;
+ memset(&ss, 0, sizeof ss);
if ((error = dns_pton(af, root_hints[i].addr, dns_sa_addr(af, &ss, NULL))))
goto error;
@@ -10866,6 +10869,7 @@ static int send_query(int argc, char *argv[]) {
struct dns_socket *so;
int error, type;
+ memset(&ss, 0, sizeof ss);
if (argc > 1) {
ss.ss_family = (strchr(argv[1], ':'))? AF_INET6 : AF_INET;