From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12186 invoked by alias); 26 Oct 2010 12:53:36 -0000 Received: (qmail 12169 invoked by uid 22791); 26 Oct 2010 12:53:35 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 12:53:22 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9QCrK02018144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Oct 2010 08:53:20 -0400 Received: from hase.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9QCrJI8017397 for ; Tue, 26 Oct 2010 08:53:20 -0400 From: Andreas Schwab To: libc-hacker@sourceware.org Subject: [PATCH] Don't require DNS labels to be host names X-Yow: If Robert Di Niro assassinates Walter Slezak, will Jodie Foster marry Bonzo?? Date: Tue, 26 Oct 2010 12:53:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00014.txt.bz2 2010-10-26 Andreas Schwab [BZ #12154] * resolv/nss_dns/dns-host.c (getanswer_r): Don't require DNS labels to be host names. (gaih_getanswer_slice): Likewise. --- resolv/nss_dns/dns-host.c | 42 ++++++++++++++++++++++++++++-------------- 1 files changed, 28 insertions(+), 14 deletions(-) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 8592183..19f6dab 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -716,7 +716,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, n = -1; } - if (__builtin_expect (n < 0 || (*name_ok) (bp) == 0, 0)) + if (__builtin_expect (n < 0 || res_dnok (bp) == 0, 0)) { ++had_error; continue; @@ -746,25 +746,29 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) { - if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1]) - continue; n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__builtin_expect (n < 0 || (*name_ok) (tbuf) == 0, 0)) + if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0)) { ++had_error; continue; } cp += n; - /* Store alias. */ - *ap++ = bp; - n = strlen (bp) + 1; /* For the \0. */ - if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) + /* Ignore aliases that are not valid host names. */ + if (res_hnok (bp)) { - ++had_error; - continue; + if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1]) + continue; + /* Store alias. */ + *ap++ = bp; + n = strlen (bp) + 1; /* For the \0. */ + if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) + { + ++had_error; + continue; + } + bp += n; + linebuflen -= n; } - bp += n; - linebuflen -= n; /* Get canonical name. */ n = strlen (tbuf) + 1; /* For the \0. */ if (__builtin_expect (n > linebuflen, 0)) @@ -892,6 +896,11 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, #endif case T_A: case T_AAAA: + if (res_hnok (bp) == 0) + { + had_error++; + break; + } if (__builtin_expect (strcasecmp (result->h_name, bp), 0) != 0) { syslog (LOG_NOTICE | LOG_AUTH, AskedForGot, result->h_name, bp); @@ -1045,7 +1054,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, n = -1; } - if (__builtin_expect (n < 0 || res_hnok (buffer) == 0, 0)) + if (__builtin_expect (n < 0 || res_dnok (buffer) == 0, 0)) { ++had_error; continue; @@ -1084,7 +1093,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, { char tbuf[MAXDNAME]; n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__builtin_expect (n < 0 || res_hnok (tbuf) == 0, 0)) + if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0)) { ++had_error; continue; @@ -1163,6 +1172,11 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, if (*firstp) { + if (res_hnok (canon ?: h_name) == 0) + { + ++had_error; + continue; + } if (ttl != 0 && ttlp != NULL) *ttlp = ttl; -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."