Major type 0 are not correctly decoded when using the additional information.
Opened this issue · 0 comments
Hi guys, there is an important bug on the AS CBOR decoder when reading and deserialize
the major type 0 (unsigned).
There is no consideration about the additional Information
with the major type 0, specifically when the additional information is major or equal than 25. For eg:
0A
(unsigned: 10) will be well decoded since the additional information is the value itself.1BFFC21BBF86CC199B
(unsigned: 18429323134567717275) it will not be well decoded, the additional information it's27
.
Following the Specification of the CBOR Encoding:
The initial byte of each encoded data item contains both information about the major type (the high-order 3 bits, described in Section 3.1) and additional information (the low-order 5 bits). With a few exceptions, the additional information's value describes how to load an unsigned integer "argument":
Less than 24:
The argument's value is the value of the additional information.24, 25, 26, or 27:
The argument's value is held in the following 1, 2, 4, or 8 bytes, respectively, in network byte order.
So, basically you're skipping the arguments values for 2, 4 and 8 bytes which as consequence will consider the value to decoded as bad formed.