public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/release/2.34/master] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)
@ 2022-09-21 18:01 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2022-09-21 18:01 UTC (permalink / raw)
  To: glibc-cvs

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

commit c36e7cca3571b0c92b09409c1df86a142596c210
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 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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-21 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 18:01 [glibc/release/2.34/master] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154) Florian Weimer

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).