Re: [Cbor] Robert Wilton's No Objection on draft-ietf-cbor-file-magic-11: (with COMMENT)

Michael Richardson <mcr+ietf@sandelman.ca> Wed, 27 April 2022 15:12 UTC

Return-Path: <mcr+ietf@sandelman.ca>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E2FC1C2C33AC; Wed, 27 Apr 2022 08:12:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=unavailable autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RVgssh_ryN0c; Wed, 27 Apr 2022 08:11:59 -0700 (PDT)
Received: from tuna.sandelman.ca (tuna.sandelman.ca [IPv6:2607:f0b0:f:3:216:3eff:fe7c:d1f3]) (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 ietfa.amsl.com (Postfix) with ESMTPS id 8AB05C39BC4A; Wed, 27 Apr 2022 08:11:54 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by tuna.sandelman.ca (Postfix) with ESMTP id 9B4A838F8D; Wed, 27 Apr 2022 11:24:33 -0400 (EDT)
Received: from tuna.sandelman.ca ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0c-rdmaahCUF; Wed, 27 Apr 2022 11:24:32 -0400 (EDT)
Received: from sandelman.ca (unknown [172.30.2.21]) by tuna.sandelman.ca (Postfix) with ESMTP id A912938F86; Wed, 27 Apr 2022 11:24:32 -0400 (EDT)
Received: from localhost (localhost [IPv6:::1]) by sandelman.ca (Postfix) with ESMTP id B548D418; Wed, 27 Apr 2022 11:11:50 -0400 (EDT)
From: Michael Richardson <mcr+ietf@sandelman.ca>
To: "Rob Wilton (rwilton)" <rwilton=40cisco.com@dmarc.ietf.org>, Carsten Bormann <cabo@tzi.org>, =?utf-8?B?Q2hyaXN0aWFuIEFtc8O8c3M=?= <christian@amsuess.com>, "cbor@ietf.org" <cbor@ietf.org>, "draft-ietf-cbor-file-magic@ietf.org" <draft-ietf-cbor-file-magic@ietf.org>, "cbor-chairs@ietf.org" <cbor-chairs@ietf.org>, The IESG <iesg@ietf.org>
In-Reply-To: <BY5PR11MB419668EE80FFF0FE9ADAAD94B5F89@BY5PR11MB4196.namprd11.prod.outlook.com>
References: <165055913687.10023.13183316329683102967@ietfa.amsl.com> <1560B380-1BB5-498F-BF33-F57B85478052@tzi.org> <BY5PR11MB4196532A7E6B9E0145225FF8B5F79@BY5PR11MB4196.namprd11.prod.outlook.com> <777507FF-4F5A-49A3-83EA-E6FCBFDCCF41@tzi.org> <BY5PR11MB419668EE80FFF0FE9ADAAD94B5F89@BY5PR11MB4196.namprd11.prod.outlook.com>
X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 27.1
X-Face: $\n1pF)h^`}$H>Hk{L"x@)JS7<%Az}5RyS@k9X%29-lHB$Ti.V>2bi.~ehC0; <'$9xN5Ub# z!G,p`nR&p7Fz@^UXIn156S8.~^@MJ*mMsD7=QFeq%AL4m<nPbLgmtKK-5dC@#:k
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha512"; protocol="application/pgp-signature"
Date: Wed, 27 Apr 2022 11:11:50 -0400
Message-ID: <29484.1651072310@localhost>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/mOF6aNcXN5hiQBMCkNhud3Lm2QY>
Subject: Re: [Cbor] Robert Wilton's No Objection on draft-ietf-cbor-file-magic-11: (with COMMENT)
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 27 Apr 2022 15:12:03 -0000

Rob Wilton \(rwilton\) <rwilton=40cisco.com@dmarc.ietf.org> wrote:
    >> > if C often does use strcpy (or even strncpy), then avoiding the zero
    >> byte isn't the only problem, it also has the risk of capturing
    >> arbitrary extra bytes which would presumably make the magic number
    >> check less reliable?
    >>
    >> That is easily avoided by using strncpy(dst, buf, 8).  But that is
    >> advice we maybe don’t want to give (see below).

    > My thought was that if a prefix of those bytes were fixed with the real
    > magic number and the remainder were arbitrary then the magic number for
    > a given file isn't fixed since it is potentially picking up contents
    > that could change with the definition of the file.  But perhaps the
    > algorithm for checking against magic numbers is designed to cope with
    > this, e.g., find the longest prefix match.

If you use Tag wrapped, then your magic number is 8 bytes, which is the
55799(4byte(  prefix.  The Sequence method is really just doing the
same thing to the content h'424f52' (BOR).
So the numbers are fixed, but you are right that some kind of longest prefix
match might make sense here.

I don't really care if we say to avoid null bytes or not.
It's just a suggestion.

I think that it makes life easier for people trying to use/find objects based
upon magic numbers.   It has been years since I've had to sit with a hex dump
and search it for evidence/rescue data.
It's slightly easier for the human with a hex dump tool to search for
sequences that have no nulls in them.  Yes, I'm talking about... in emacs with hexl-mode.

--
Michael Richardson <mcr+IETF@sandelman.ca>   . o O ( IPv6 IøT consulting )
           Sandelman Software Works Inc, Ottawa and Worldwide