From patchwork Thu Jul 8 15:00:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44225 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 6A71539960D4 for ; Thu, 8 Jul 2021 15:02:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A71539960D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625756576; bh=ZAl7sbuM3XQ1rwcYrd1DhMpLeJ/ZLhjWmexSpnVy5Ac=; 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=cuU2MH/syannlxsvwi4lrpOv0AV9j/4/Jw/eUC70ucPxS+bJeBWnIsdrg3nGGKNNt jcLXEhL0O+C8OS8BI4mIXZ4IKcED2Xl9qgheCO2DRnqScxnCwZcRSPersIpKPUgGz5 fHUWRHbm7v84YGDDN+yaXhFKJ1ldLqOpHxgr8T+o= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 2CB9B3939C2E for ; Thu, 8 Jul 2021 15:00:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2CB9B3939C2E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-vdmNdQRiOk2qJ36vXYEqFw-1; Thu, 08 Jul 2021 11:00:18 -0400 X-MC-Unique: vdmNdQRiOk2qJ36vXYEqFw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91F0ADF8C6 for ; Thu, 8 Jul 2021 15:00:03 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E88E88D5BD for ; Thu, 8 Jul 2021 15:00:02 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 04/30] nss_dns: Do not use deprecated packet parsing functions In-Reply-To: References: X-From-Line: 8eab562b79d8cfc647668a5a669baec4f303ba93 Mon Sep 17 00:00:00 2001 Message-Id: <8eab562b79d8cfc647668a5a669baec4f303ba93.1625755445.git.fweimer@redhat.com> Date: Thu, 08 Jul 2021 17:00:00 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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" --- resolv/nss_dns/dns-canon.c | 13 ++++++++----- resolv/nss_dns/dns-host.c | 28 ++++++++++++---------------- 2 files changed, 20 insertions(+), 21 deletions(-) Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell diff --git a/resolv/nss_dns/dns-canon.c b/resolv/nss_dns/dns-canon.c index cb321a0650..1cdc9a86c9 100644 --- a/resolv/nss_dns/dns-canon.c +++ b/resolv/nss_dns/dns-canon.c @@ -150,15 +150,18 @@ _nss_dns_getcanonname_r (const char *name, char *buffer, size_t buflen, if (type != ns_t_cname) goto unavail; - if (__ns_get16 (ptr) != ns_c_in) + uint16_t rrclass; + NS_GET16 (rrclass, ptr); + if (rrclass != ns_c_in) goto unavail; - /* Also skip over class and TTL. */ - ptr += sizeof (uint16_t) + sizeof (uint32_t); + /* Skip over TTL. */ + ptr += sizeof (uint32_t); /* Skip over RDATA length and RDATA itself. */ - uint16_t rdatalen = __ns_get16 (ptr); - ptr += sizeof (uint16_t); + uint16_t rdatalen; + NS_GET16 (rdatalen, ptr); + /* Not enough room for RDATA. */ if (endptr - ptr < rdatalen) goto unavail; diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 47e851db55..d6a69a602a 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -782,14 +782,11 @@ getanswer_r (struct resolv_context *ctx, continue; } - type = __ns_get16 (cp); - cp += INT16SZ; /* type */ - class = __ns_get16 (cp); - cp += INT16SZ; /* class */ - int32_t ttl = __ns_get32 (cp); - cp += INT32SZ; /* TTL */ - n = __ns_get16 (cp); - cp += INT16SZ; /* len */ + NS_GET16 (type, cp); + NS_GET16 (class, cp); + int32_t ttl; + NS_GET32 (ttl, cp); + NS_GET16 (n, cp); /* RDATA length. */ if (end_of_message - cp < n) { @@ -1116,14 +1113,13 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, continue; } - int type = __ns_get16 (cp); - cp += INT16SZ; /* type */ - int class = __ns_get16 (cp); - cp += INT16SZ; /* class */ - int32_t ttl = __ns_get32 (cp); - cp += INT32SZ; /* TTL */ - n = __ns_get16 (cp); - cp += INT16SZ; /* len */ + uint16_t type; + NS_GET16 (type, cp); + uint16_t class; + NS_GET16 (class, cp); + int32_t ttl; + NS_GET32 (ttl, cp); + NS_GET16 (n, cp); /* RDATA length. */ if (end_of_message - cp < n) {