fix: only allow minimally encoded CID tag#55
Merged
Conversation
rvagg
reviewed
May 15, 2026
rvagg
reviewed
May 15, 2026
| DecodeError::Mismatch { | ||
| name: "CBOR tag", | ||
| found: 0xf7 | ||
| found: 0xd9 |
Member
There was a problem hiding this comment.
this passes whether we report head or the byte after it, since both are 0xd9. Some better inputs that distinguish:
- over-wide encoding of tag 42, assertion should be
found: 0xd9(the head):0xd9, 0x00, 0x2a, 0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72 - minimally-encoded header but wrong tag number, assertion should be
found: 0x29:0xd8, 0x29
The first exercises the head-width check; the second exercises the tag-value check.
Integers should always be minimally encoded, so should be the header of a tag.
90e3ff1 to
97a7943
Compare
rvagg
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integers should always be minimally encoded, so should be the header of a tag.