From 618fa4513081033024657fe71812ae08500b6871 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Thu, 8 Dec 2016 14:47:44 -0800 Subject: [PATCH 1/3] Non-canonical LEB128 We've discussed this before, but the spec doesn't mention it. --- BinaryEncoding.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 57bd1a8f..b3777c24 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -53,6 +53,15 @@ represented by _at most_ ceil(_N_/7) bytes that may contain padding `0x80` or `0 Note: Currently, the only sizes used are `varint7`, `varint32` and `varint64`. +### Non-canonical LEB128 + +Both `varuintN` and `varintN` can be encoded with non-canonical LEB128 values where: + +* non-significant zero `0x80` bytes are present in an over-large encoding; and / or +* non-significant LEB128 bits are ignored. + +In both cases, the _N_ bit limitation applies. + ## Language Types All types are distinguished by a negative `varint7` values that is the first byte of their encoding (representing a type constructor): From 8c0b88f92c988511244188304b642bdce9f61a89 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Thu, 8 Dec 2016 14:57:46 -0800 Subject: [PATCH 2/3] s/significant/relevant/ --- BinaryEncoding.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index b3777c24..86502f28 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -57,8 +57,8 @@ Note: Currently, the only sizes used are `varint7`, `varint32` and `varint64`. Both `varuintN` and `varintN` can be encoded with non-canonical LEB128 values where: -* non-significant zero `0x80` bytes are present in an over-large encoding; and / or -* non-significant LEB128 bits are ignored. +* non-relevant zero `0x80` bytes are present in an over-large encoding; and / or +* non-relevant LEB128 bits (bits past the size) are ignored. In both cases, the _N_ bit limitation applies. From 761eeb3650185c50a60d60c25c1b37b1df9d2b90 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Thu, 8 Dec 2016 20:07:28 -0800 Subject: [PATCH 3/3] Rephrase the size limit --- BinaryEncoding.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 86502f28..342df9c7 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -55,12 +55,12 @@ Note: Currently, the only sizes used are `varint7`, `varint32` and `varint64`. ### Non-canonical LEB128 -Both `varuintN` and `varintN` can be encoded with non-canonical LEB128 values where: +Both `varuintN` and `varintN` can be encoded with *non-canonical* LEB128 values where: * non-relevant zero `0x80` bytes are present in an over-large encoding; and / or * non-relevant LEB128 bits (bits past the size) are ignored. -In both cases, the _N_ bit limitation applies. +The total number of bytes used to encode the `varuintN` / `varintN` cannot exceed the largest *canonical* encoding for that `varuintN` / `varintN`. ## Language Types