public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.35/master] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)
Date: Tue, 20 Sep 2022 11:07:39 +0000 (GMT)	[thread overview]
Message-ID: <20220920110739.781593858427@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=519e1b025113c338852933d71acfc9d163658cfe

commit 519e1b025113c338852933d71acfc9d163658cfe
Author: Florian Weimer <fweimer@redhat.com>
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 <siddhesh@sourceware.org>
    (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 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)

                 reply	other threads:[~2022-09-20 11:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220920110739.781593858427@sourceware.org \
    --to=fw@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).