From patchwork Fri Aug 26 10:34:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 57088 X-Patchwork-Delegate: siddhesh@gotplt.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5BA238C17FC for ; Fri, 26 Aug 2022 10:36:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5BA238C17FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661510178; bh=UPiXctqo149OnGJ+q7CAciN8ak/BEMuxA8kBblZcCYs=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=I3A6YzAkF64Wh9DAi2WdJIJiHqax1MERNJvO8AcyiEiBFpKNroaxHPZaS6cEokdoo +6W/nVaaqQM9Ri2uohdRkEioh14RHPuaxzNOf7N77VzwNoG9E9XGvKbUxz/8qfwMAL riPHr3kNQkYpgZbMDiGLro+mtwLojQuPO67+kluk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 26403384A04C for ; Fri, 26 Aug 2022 10:34:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 26403384A04C Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-548-MyN54p-IMje3a2dMDorwSA-1; Fri, 26 Aug 2022 06:34:10 -0400 X-MC-Unique: MyN54p-IMje3a2dMDorwSA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 521FA3826255 for ; Fri, 26 Aug 2022 10:34:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0012492C3B for ; Fri, 26 Aug 2022 10:34:09 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v2 11/13] nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154) In-Reply-To: References: X-From-Line: 6623fbcf77c0a1767515098a41368551a456154c Mon Sep 17 00:00:00 2001 Message-Id: <6623fbcf77c0a1767515098a41368551a456154c.1661509943.git.fweimer@redhat.com> Date: Fri, 26 Aug 2022 12:34:05 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 --- 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)