Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBOR: Reject malformed and invalid indefinite-length strings #405

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

benluddy
Copy link
Contributor

Tests and potential fix for #403 and #404.

Makes decode return a error if a byte string is nested within an indefinite-length text string, or a text string is nested within an indefinite-length byte string. Separately, if the decode option ValidateUnicode is enabled, it will also apply to text strings that are nested within an indefinite-length text string.

Per the CBOR spec, each chunk of an indefinite-length text string must be valid, or the entire
indefinite-length string is invalid.
An indefinite-length text or byte string is not well-formed unless all of its chunks are of the same
major type as the indefinite-length string.
This addresses two conformance issues:

1. All chunks of an indefinite-length text string must be valid, so if UTF-8 validation is enabled
for text strings in DecodeOptions, it should be applied to each chunk.

2. All of the chunks of an indefinite-length text or byte string must have the same major type as
the indefinite-length string itself. Indefinitely-length text strings can't contain byte strings and
vice versa.
@ugorji ugorji merged commit f7f63a0 into ugorji:master Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants