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

Array/map not checked when inlined into enum #175

Closed
rooooooooob opened this issue Apr 14, 2023 · 0 comments · Fixed by #217
Closed

Array/map not checked when inlined into enum #175

rooooooooob opened this issue Apr 14, 2023 · 0 comments · Fixed by #217

Comments

@rooooooooob
Copy link
Collaborator

overlapping_inlined = [
	0 //
	0, uint //
	0, uint, text
]

Will not work as some variants are subsets of other ones so will incorrectly parse as one of the other variants without checking the array/map length here.

When you do this not inlined like:

overlapping0 = [0]
overlapping1 = [0, uint]
overlapping2 = [0, uint, text]

overlapping = overlapping0 / overlapping1 / overlapping2

there is no problem as this is taken care of in the dedicated structs' deserializes.

rooooooooob added a commit that referenced this issue Dec 12, 2023
Fixes #175

Now properly checks all lengths for all variants to ensure that
overlapping types parse the correct variant instead of prematurely
thinking it's a subset of one.

Also fixes having CBORReadLen contributions from previous variants that
tried to parse from contributing to later variant parses (possibly
causing issues if it meant it already hit the limit).

Includes support for optional fields within enums that get inlined.

Tests for both cases.
SebastienGllmt pushed a commit that referenced this issue Dec 15, 2023
* Enum length-check fixes + Enum optional field support

Fixes #175

Now properly checks all lengths for all variants to ensure that
overlapping types parse the correct variant instead of prematurely
thinking it's a subset of one.

Also fixes having CBORReadLen contributions from previous variants that
tried to parse from contributing to later variant parses (possibly
causing issues if it meant it already hit the limit).

Includes support for optional fields within enums that get inlined.

Tests for both cases.

* preserve-encodings tests for overlapping_inlined + enum_opt_embed_fields
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 a pull request may close this issue.

1 participant