You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
TinyCBOR may assert when decoding if it gets out of sync with the end of a container. This was discovered when attempting to decode an endpoint that used the "dtn" scheme as opposed to the "ipn" scheme. BPLib does not currently support the dtn scheme, and the internal decoding error flag was set as expected, but it still tried to "close" the container in the TinyCBOR state. This caused TinyCBOR to assert.
To Reproduce
Pass in a bundle from the CLA that uses a "dtn" scheme endpoint ID.
if (cbor_value_leave_container(parent, &content) !=CborNoError)
In this case the dec->error flag was already set due to the decode issue, but the cbor_value_leave_container() is still called. This caused TinyCBOR to assert because it wasn't at the end of the container.
System observed on:
Debian with TinyCBOR 0.60
Additional context
The code must not make any additional calls into TinyCBOR once the error flag is set, as it will be out of sync.
Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered:
Implement the encoding and decoding of CBOR containers as a loop. This
permits the "error" flag to be easily polled after each iteration, and
if it is ever set, the operation should exit safely.
This is important because after any encode/decode issue, the tiny CBOR
state will no longer be in sync with the data, and this library may
assert if invoked with a bad state object.
jphickey
added a commit
to jphickey/bplib
that referenced
this issue
Sep 20, 2023
Implement the encoding and decoding of CBOR containers as a loop. This
permits the "error" flag to be easily polled after each iteration, and
if it is ever set, the operation should exit safely.
This is important because after any encode/decode issue, the tiny CBOR
state will no longer be in sync with the data, and this library may
assert if invoked with a bad state object.
Describe the bug
TinyCBOR may assert when decoding if it gets out of sync with the end of a container. This was discovered when attempting to decode an endpoint that used the "dtn" scheme as opposed to the "ipn" scheme. BPLib does not currently support the dtn scheme, and the internal decoding error flag was set as expected, but it still tried to "close" the container in the TinyCBOR state. This caused TinyCBOR to assert.
To Reproduce
Pass in a bundle from the CLA that uses a "dtn" scheme endpoint ID.
Expected behavior
Should not assert
Code snips
This is the line that asserted:
bplib/v7/src/v7_bp_container.c
Lines 104 to 110 in 3910733
In this case the
dec->error
flag was already set due to the decode issue, but thecbor_value_leave_container()
is still called. This caused TinyCBOR to assert because it wasn't at the end of the container.System observed on:
Debian with TinyCBOR 0.60
Additional context
The code must not make any additional calls into TinyCBOR once the error flag is set, as it will be out of sync.
Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: