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

Carsten Bormann <cabo@tzi.org> Thu, 21 April 2022 17:07 UTC

Return-Path: <cabo@tzi.org>
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 D1B433A1855; Thu, 21 Apr 2022 10:07:46 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bedsSMjqzECH; Thu, 21 Apr 2022 10:07:43 -0700 (PDT)
Received: from gabriel-smtp.zfn.uni-bremen.de (gabriel-smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::15]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B56D33A11DD; Thu, 21 Apr 2022 10:07:40 -0700 (PDT)
Received: from [192.168.217.118] (p5089ad4f.dip0.t-ipconnect.de [80.137.173.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4KkkVx0dqKzDCcd; Thu, 21 Apr 2022 19:07:37 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <165055913687.10023.13183316329683102967@ietfa.amsl.com>
Date: Thu, 21 Apr 2022 19:07:36 +0200
Cc: The IESG <iesg@ietf.org>, Christian Amsüss <christian@amsuess.com>, cbor@ietf.org, cbor-chairs@ietf.org, draft-ietf-cbor-file-magic@ietf.org
X-Mao-Original-Outgoing-Id: 672253656.806302-c4cef415978ccde35ee38a2d203eb0dc
Content-Transfer-Encoding: quoted-printable
Message-Id: <1560B380-1BB5-498F-BF33-F57B85478052@tzi.org>
References: <165055913687.10023.13183316329683102967@ietfa.amsl.com>
To: Robert Wilton <rwilton@cisco.com>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/4sZ-T8POSwhcSrsxoz3JGP-KeqM>
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.29
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: Thu, 21 Apr 2022 17:07:47 -0000

Hi Rob,

thank you for this input.

> The document, along with other ballot positions, can be found here:
> https://datatracker.ietf.org/doc/draft-ietf-cbor-file-magic/
> ----------------------------------------------------------------------
> COMMENT:
> ----------------------------------------------------------------------
> 
> Hi,
> 
> Apologies for a late review, and there is just one none blocking issue that I
> wanted to raise:
> 
>   It is further
>   suggested to avoid values that have an embedded zero byte in the four
>   bytes of their binary representation (such as 0x12003456), as these
>   may confuse implementations that treat the magic number as a C
>   string.
> 
> I was less convinced by this statement because:
> (1) It seems like C treating this as null terminated string is probably not the
> right thing to do,

It is not, but I have seen too much code doing that with magic numbers (strncpy, that is).

> I'm not sure that we should be implicitly endorsing that.

Of course, we could decide that we make zero bytes prominent enough and mention that strncpy is not the way to do this.

> (2) When translating values from the Content-Format registry means that this
> issue is presumably unavoidable.  I.e., it looks like your example in 2.2.1
> violates this guidance.

It does.

This is easy to fix by using

0x63740000 + (ct / 255 + 1) * 256 + ct % 255 + 1

as the tag number (*).

So we have the choice between 

(1) not suggesting avoiding zero bytes or 
(2) making the above change to the content—format-number to tag-number mapping.

Grüße, Carsten

(*) Generally, this will not be a runtime computation, as the content-format number will be looked up manually and translated into a tag number using a formula at or before compiling — the difference is just the complexity of the formula.