aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-08-30 10:02:49 +0200
committerAndreas K. Hüttel <dilfridge@gentoo.org>2022-10-01 22:22:17 +0200
commit7b8d5e9f89bf913b2380beb9c3193b8d7ef07fd5 (patch)
treea3b2d8bcfdb75d82661a0664a4841da5579e7134
parentnss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305) (diff)
downloadglibc-7b8d5e9f89bf913b2380beb9c3193b8d7ef07fd5.tar.gz
glibc-7b8d5e9f89bf913b2380beb9c3193b8d7ef07fd5.tar.bz2
glibc-7b8d5e9f89bf913b2380beb9c3193b8d7ef07fd5.zip
nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)
If the name is not a host name, skip adding it to the result, instead of reporting query failure. This fixes bug 12154 for getaddrinfo. This commit still keeps the old parsing code, and only adjusts when a host name is copied. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> (cherry picked from commit 32b599ac8c21c4c332cc3900a792a1395bca79c7) (cherry picked from commit 519e1b025113c338852933d71acfc9d163658cfe)
-rw-r--r--resolv/nss_dns/dns-host.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index b1bdb3018b..484a6289d5 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -948,12 +948,12 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
n = -1;
}
- if (__glibc_unlikely (n < 0 || __libc_res_hnok (buffer) == 0))
+ if (__glibc_unlikely (n < 0))
{
++had_error;
continue;
}
- if (*firstp && canon == NULL)
+ if (*firstp && canon == NULL && __libc_res_hnok (buffer))
{
h_name = buffer;
buffer += h_namelen;
@@ -999,14 +999,14 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
n = __libc_dn_expand (answer->buf, end_of_message, cp,
tbuf, sizeof tbuf);
- if (__glibc_unlikely (n < 0 || __libc_res_hnok (tbuf) == 0))
+ if (__glibc_unlikely (n < 0))
{
++had_error;
continue;
}
cp += n;
- if (*firstp)
+ if (*firstp && __libc_res_hnok (tbuf))
{
/* Reclaim buffer space. */
if (h_name + h_namelen == buffer)