diff options
author | NIIBE Yutaka <[email protected]> | 2018-06-18 01:13:35 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2018-06-18 08:27:07 +0000 |
commit | 87d0ecf8a1b80139a6cab2a79f1ca6e287207999 (patch) | |
tree | f16e225b83989dc05fd5730b6b9091f9ff5bbaad /dirmngr/dns.c | |
parent | libdns: Fix connect and try next nameserver when ECONNREFUSED. (diff) | |
download | gnupg-87d0ecf8a1b80139a6cab2a79f1ca6e287207999.tar.gz gnupg-87d0ecf8a1b80139a6cab2a79f1ca6e287207999.zip |
libdns: Fix for non-FQDN hostname.
* dirmngr/dns.c (dns_resconf_open): Clear search[0] for non-FQDN
hostname.
--
Cherry pick from master commit:
a4a054bf14fa855715faee01a152755c4e2a74f7
GnuPG-bug-id: T3803
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'dirmngr/dns.c')
-rw-r--r-- | dirmngr/dns.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/dirmngr/dns.c b/dirmngr/dns.c index d2445a0c6..908bf157a 100644 --- a/dirmngr/dns.c +++ b/dirmngr/dns.c @@ -5371,13 +5371,16 @@ struct dns_resolv_conf *dns_resconf_open(int *error) { if (0 != gethostname(resconf->search[0], sizeof resconf->search[0])) goto syerr; - dns_d_anchor(resconf->search[0], sizeof resconf->search[0], resconf->search[0], strlen(resconf->search[0])); - dns_d_cleave(resconf->search[0], sizeof resconf->search[0], resconf->search[0], strlen(resconf->search[0])); - /* - * XXX: If gethostname() returned a string without any label - * separator, then search[0][0] should be NUL. + * If gethostname() returned a string without any label + * separator, then search[0][0] should be NUL. */ + if (strchr (resconf->search[0], '.')) { + dns_d_anchor(resconf->search[0], sizeof resconf->search[0], resconf->search[0], strlen(resconf->search[0])); + dns_d_cleave(resconf->search[0], sizeof resconf->search[0], resconf->search[0], strlen(resconf->search[0])); + } else { + memset (resconf->search[0], 0, sizeof resconf->search[0]); + } dns_resconf_acquire(resconf); |