]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)
authorFlorian Weimer <fweimer@redhat.com>
Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 21 Sep 2022 17:37:24 +0000 (19:37 +0200)
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)

resolv/nss_dns/dns-host.c

index f691e79949330f429c38938cf5139799d52be256..2d8b839568f19df29aaa912494448edb6f548393 100644 (file)
@@ -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)