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

bug: Marshal can produce malformed CBOR when marshaling a cbor.Marshaler that produces malformed CBOR #482

Closed
benluddy opened this issue Jan 31, 2024 · 1 comment · Fixed by #485
Assignees
Labels
bug Something isn't working
Milestone

Comments

@benluddy
Copy link
Contributor

What version of fxamacker/cbor are you using?

v2.5.0

Does this issue reproduce with the latest release?

Yes.

What OS and CPU architecture are you using (go env)?

go env Output
$ go env

What did you do?

Marshaled RawMessage([]byte{0xa6}) without error, then called Wellformed on the output.

https://go.dev/play/p/n_OxskfI3oA

What did you expect to see?

I expected the call to Marshal to return a non-nil error refusing to output malformed CBOR.

What did you see instead?

The Marshaler (in this case a RawMessage) is trusted to produce well-formed CBOR, and as a result the output from Marshal is not well-formed.

@fxamacker
Copy link
Owner

@benluddy Thanks for finding and reporting this bug! 👍

I'll open a PR to fix this by rejecting malformed CBOR data from Marshaler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants