From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DE4291F8C6 for ; Thu, 15 Jul 2021 05:02:36 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A48239A28C9 for ; Thu, 15 Jul 2021 05:02:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A48239A28C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626325356; bh=v6QYvcWILbuj6iELJeb+U8SeXxdWK58PUCICIxdAqok=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gF86PySHuA6rV7R8H2ZYRkgbbGUicX9Rapio6KUuVsPwjAhYx3ot503MgvCTEHom/ skv422jXFn+QuNw9GseIyetRZLK6iE5c6Gi9/9GSeZsxJgml1bzUSan9IH1klOJfrk Yeno9cFbypu0eP/RxuOQNFolxGYpO/dW7DrB7he8= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 8B3F738515EA for ; Thu, 15 Jul 2021 05:00:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B3F738515EA Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-NcEY68LaN-eEGl-AauZwgA-1; Thu, 15 Jul 2021 01:00:03 -0400 X-MC-Unique: NcEY68LaN-eEGl-AauZwgA-1 Received: by mail-qt1-f197.google.com with SMTP id e7-20020ac84e470000b029025ca4fbcc12so3103437qtw.18 for ; Wed, 14 Jul 2021 22:00:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=v6QYvcWILbuj6iELJeb+U8SeXxdWK58PUCICIxdAqok=; b=f+3+OIt2XniRyzO8lkmAHrK+K3wdfUcVMD8ovfczYw6zUA6kPikvy+GwIObr81VCae tfEh/7h4EEluljQ1X+Uzcco3N8txtILbg7TregfN4rz1JxBoJwnOMaO1T5HbUbpalQaJ 9YalcnLPC/7Ca2bL00PZKag0dd+0HhnRZy5MFWrmbUjv2ZeabzwE/VTBYR+IbNsQ4kb5 k8iLfms2x+Z390iEEsJHtcxIDd48Xbr2x0Y1ieSQI4YEupRw2FtmIngAFmnReFF07g9t /TlEBBu1w3mWkIRATPENBPLFx2/Dy2kW5wHAt7LUvWPFokg8XkOJJxFpNCqlj8pVZK5c 5RzA== X-Gm-Message-State: AOAM530Zc/nmCBU72T2uNVwAeumL0VRK3iW3CACEvZm7xig0f1p9e+wH Pau01pMKeYqW1w2+6GeZgTt4kqM48Au+IXuXml5tvQbt+aJDEPq2qkWJgsTj+WKYRNvBmrG7M45 sk3ZsjwrRnPlps01Tg/kpIEiW0qqGmBuZb7EbKQmtnHeN9026uHm09xBpi7N327fw9bcj9Q== X-Received: by 2002:a05:622a:24f:: with SMTP id c15mr2173539qtx.2.1626325202498; Wed, 14 Jul 2021 22:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHBrE3mj70mTBLpWz8INY9RlHvzKf1B/+WrOriJ9P08dhb/4/JsJDAIoPqWkQDftD4upKnMQ== X-Received: by 2002:a05:622a:24f:: with SMTP id c15mr2173515qtx.2.1626325202281; Wed, 14 Jul 2021 22:00:02 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id p22sm1640564qtq.64.2021.07.14.22.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 22:00:01 -0700 (PDT) Subject: Re: [PATCH 04/30] nss_dns: Do not use deprecated packet parsing functions To: Florian Weimer , libc-alpha@sourceware.org References: <8eab562b79d8cfc647668a5a669baec4f303ba93.1625755445.git.fweimer@redhat.com> Organization: Red Hat Message-ID: <88f44288-397c-6da6-2fc7-78e0b9fc2426@redhat.com> Date: Thu, 15 Jul 2021 01:00:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <8eab562b79d8cfc647668a5a669baec4f303ba93.1625755445.git.fweimer@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , From: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 7/8/21 11:00 AM, Florian Weimer via Libc-alpha wrote: OK for glibc 2.34. Tested without regression on x86_64 and i686. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > --- > resolv/nss_dns/dns-canon.c | 13 ++++++++----- > resolv/nss_dns/dns-host.c | 28 ++++++++++++---------------- > 2 files changed, 20 insertions(+), 21 deletions(-) > > 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) OK. This advances by NS_INT16SZ (which previously did not). > goto unavail; > > - /* Also skip over class and TTL. */ > - ptr += sizeof (uint16_t) + sizeof (uint32_t); > + /* Skip over TTL. */ > + ptr += sizeof (uint32_t); OK. This fixes the advance. > > /* Skip over RDATA length and RDATA itself. */ > - uint16_t rdatalen = __ns_get16 (ptr); > - ptr += sizeof (uint16_t); > + uint16_t rdatalen; > + NS_GET16 (rdatalen, ptr); OK. No ptr += because NS_GET16 advances by NS_INT16SZ. > + > /* 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. */ OK. > > 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. */ OK. > > if (end_of_message - cp < n) > { > -- Cheers, Carlos.