From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 6A62B3851A8E; Tue, 13 Sep 2022 11:23:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A62B3851A8E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663068231; bh=X7fikfLprdfe9PjTm0BG3526rBPWSC0CS1g1HAt9QRI=; h=From:To:Subject:Date:From; b=x+Jn4Hiy0KT30uqKp0gtdax5nx55KJ8D4GYvSD9fK0owwrN5tosnBECl8isNKozhw VYWFkr6V1ekVeEWTLmI54xC3j1hJ3zEXoyM5pnOwX5R5mTtJjytk5sJp10ErR/CiHy 2v0qua09B4/l15KEfUNx1BROYCWRJ+Wdn2pJozcQ= 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.36/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.36/master X-Git-Oldrev: 78c8ef21fa54e994451d5b42ead6080d99a88a49 X-Git-Newrev: 7a236dc44a22dc4252e803d1ee1d3b970ec43805 Message-Id: <20220913112351.6A62B3851A8E@sourceware.org> Date: Tue, 13 Sep 2022 11:23:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7a236dc44a22dc4252e803d1ee1d3b970ec43805 commit 7a236dc44a22dc4252e803d1ee1d3b970ec43805 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 b887e77e9c..bea505d697 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -970,12 +970,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; @@ -1021,14 +1021,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)