From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 9B0763857B97; Wed, 21 Sep 2022 18:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B0763857B97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663783289; bh=vE5ot9fIOx2063lg7oSRx1vq30adQWTGL8imUXBd4hg=; h=From:To:Subject:Date:From; b=GrnLw1TiTnMoZZOUx4jhfye2LB2vtigu9sB/iQdfGnFQiIwTLeVQv+HmfGiRI4AGW HKpCuE/G0RKYHBos4i1wHkKdSCw9gwT9mU3tJcSZ5gvSW4fR8H4JaJjtRuisUCkyNt ORyMHm4ZnVDWe9Lsv3sl459wo4LfO4bh7h/rdfcA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc/release/2.34/master] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154) X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/release/2.34/master X-Git-Oldrev: 9abc40d9b514fc51cd1a052d32d092a827c6e21a X-Git-Newrev: c36e7cca3571b0c92b09409c1df86a142596c210 Message-Id: <20220921180129.9B0763857B97@sourceware.org> Date: Wed, 21 Sep 2022 18:01:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c36e7cca3571b0c92b09409c1df86a142596c210 commit c36e7cca3571b0c92b09409c1df86a142596c210 Author: Florian Weimer Date: Tue Aug 30 10:02:49 2022 +0200 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 (cherry picked from commit 32b599ac8c21c4c332cc3900a792a1395bca79c7) Diff: --- resolv/nss_dns/dns-host.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index f691e79949..2d8b839568 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -949,12 +949,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; @@ -1000,14 +1000,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)