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

Fix cbor.SimpleValue encoding and decoding #464

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

fxamacker
Copy link
Owner

Closes #462 #463

  1. Encoding cbor.SimpleValue with values 24..31 should fail because CBOR simple values 24..31 are reserved and they MUST NOT be encoded according to RFC 8949.

    This PR makes encoder return UnsupportedValueError when encoding cbor.SimpleValue with values 24..31 because that would not be a well-formed CBOR data item.

  2. Decoding other CBOR types to cbor.SimpleValue should fail because cbor.SimpleValue represents CBOR simple value (major type 7) which is different from CBOR integers and shouldn't be used interchangeably.

    This PR makes decoder return UnmarshalTypeError when decoding other CBOR types to cbor.SimpleValue.

This commit resolves two issues:

1.  Encoding cbor.SimpleValue with values 24..31 should fail because
CBOR simple values 24..31 are reserved and they MUST NOT be encoded
according to RFC 8949.

This commit makes encoder return UnsupportedValueError when encoding
cbor.SimpleValue with values 24..31 because that would not be
a well-formed CBOR data item.

2. Decoding other CBOR types to cbor.SimpleValue should fail because
cbor.SimpleValue represents CBOR simple value (major type 7) which is
different from CBOR integers and shouldn't be used interchangeably.

This commit makes decoder return UnmarshalTypeError when decoding
other CBOR types to cbor.SimpleValue.
@fxamacker fxamacker added this to the v2.6.0 milestone Jan 2, 2024
Copy link
Contributor

@x448 x448 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@fxamacker fxamacker merged commit f4ccee0 into master Jan 2, 2024
17 checks passed
@fxamacker fxamacker deleted the fxamacker/refactor-simple-value branch September 7, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: prevent decoding other CBOR types to cbor.SimpleValue
2 participants