From patchwork Wed Aug 10 09:30:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1665167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Yfq4+GGt; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M2l6L3bjPz9sGt for ; Wed, 10 Aug 2022 19:30:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DE5D385AE4F for ; Wed, 10 Aug 2022 09:30:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DE5D385AE4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660123832; bh=cvWknfYbHPli+Ej0a/v5NF0uwgOOsV7u0mN7wLT5xxY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Yfq4+GGt35dnsCEkoZ5QzAhEUnpplHyhwiEoQxa/DYMPqnAIUAKOmiPnP2M/caEWv dq3FVnpNtoI1WuHBI0erEaakaIszhCnDEGCTD2+yVKB35qpBfQbG4up31ZtVQM0wYh efQRU97a7rwOxYY3bT3dtCsH4UlUhb0w1tTuJBzA= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id CC0223856DE2 for ; Wed, 10 Aug 2022 09:30:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC0223856DE2 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-PHYH8JYYNt-xDtGnEh3t_Q-1; Wed, 10 Aug 2022 05:30:16 -0400 X-MC-Unique: PHYH8JYYNt-xDtGnEh3t_Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA53685A5B9 for ; Wed, 10 Aug 2022 09:30:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C07A404754B for ; Wed, 10 Aug 2022 09:30:15 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 00/13] nss_dns: Fix handling of non-host CNAMEs (bug 12154) X-From-Line: 2a52948e0655cd2c5a81ea654259b6303aefe3c0 Mon Sep 17 00:00:00 2001 Message-Id: Date: Wed, 10 Aug 2022 11:30:13 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, 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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This series is my last attempt at fixing bug 12154. The bug is that some sites have names like *.wildcard.example.org in their CNAME chains, and we fail lookup completely instead of suppressing that invalid host names. The changes are more involved than I would have liked, but each time I think I have a simple fix, I end up rewriting the DNS parsers. Tested on i686-linux-gnu and x86_64-linux-gnu. Thanks, Florian Florian Weimer (13): resolv: Add tst-resolv-byaddr for testing reverse lookup resolv: Add tst-resolv-aliases resolv: Add internal __res_binary_hnok function resolv: Add the __ns_samebinaryname function resolv: Add internal __ns_name_length_uncompressed function resolv: Add DNS packet parsing helpers geared towards wire format nss_dns: Split getanswer_ptr from getanswer_r nss_dns: Rewrite _nss_dns_gethostbyaddr2_r and getanswer_ptr nss_dns: Remove remnants of IPv6 address mapping nss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305) nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154) resolv: Add new tst-resolv-invalid-cname nss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfaces include/arpa/nameser.h | 106 ++ include/resolv.h | 3 + resolv/Makefile | 23 + resolv/README | 3 - resolv/mapv4v6addr.h | 69 -- resolv/mapv4v6hostent.h | 84 -- resolv/ns_name_length_uncompressed.c | 72 ++ resolv/ns_rr_cursor_init.c | 62 ++ resolv/ns_rr_cursor_next.c | 74 ++ resolv/ns_samebinaryname.c | 55 + resolv/nss_dns/dns-host.c | 1184 +++++++++------------- resolv/res-name-checking.c | 14 +- resolv/tst-ns_name_length_uncompressed.c | 135 +++ resolv/tst-ns_rr_cursor.c | 227 +++++ resolv/tst-ns_samebinaryname.c | 62 ++ resolv/tst-resolv-aliases.c | 267 +++++ resolv/tst-resolv-byaddr.c | 339 +++++++ resolv/tst-resolv-invalid-cname.c | 406 ++++++++ 18 files changed, 2303 insertions(+), 882 deletions(-) delete mode 100644 resolv/mapv4v6addr.h delete mode 100644 resolv/mapv4v6hostent.h create mode 100644 resolv/ns_name_length_uncompressed.c create mode 100644 resolv/ns_rr_cursor_init.c create mode 100644 resolv/ns_rr_cursor_next.c create mode 100644 resolv/ns_samebinaryname.c create mode 100644 resolv/tst-ns_name_length_uncompressed.c create mode 100644 resolv/tst-ns_rr_cursor.c create mode 100644 resolv/tst-ns_samebinaryname.c create mode 100644 resolv/tst-resolv-aliases.c create mode 100644 resolv/tst-resolv-byaddr.c create mode 100644 resolv/tst-resolv-invalid-cname.c base-commit: 2ed26bca997a8fc898f4cb94484abaee2f307311