-
Notifications
You must be signed in to change notification settings - Fork 61
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
Using ByteSliceMode
(unreleased new feature) can encode invalid CBOR data
#545
Comments
That's unfortunate. This is a validity error, but the output is not malformed, correct? Marshaling a It's not clear to me what should be done about this. I think it makes sense to check tag validity on the output of Roundtripping an enclosed data item through interface{} and back without considering the tag number will never be completely safe, but I can imagine an argument to at least decouple |
Yes, it is a validity error.
I think decoupling |
ByteSliceMode
(unreleased new feature) can encode malformed dataByteSliceMode
(unreleased new feature) can encode invalid CBOR data
Yes, I expect it would be a breaking change since we can come up with a value of Now that I've had time to consider this more, I want to implement a fix. I also want to make sure that I'm addressing the right issue, so please let me try to break down my understanding of the problem:
Given all this, I don't think that the requirement is that To address the immediate issue, I propose special-casing this in Later, a new "strongly encouraged opt-in" mode for I'll try to get a PR open today for consideration. |
ByteSliceMode
is a new feature planned for v2.7.0 (not yet released) and was added by:Unfortunately, using the non-default encoding setting for
ByteSliceMode
can produce invalid CBOR data in some edge cases.This problem was discovered by fuzzing.
Reproducer
Steps:
ByteSliceMode
set to any non-default optioncbor.Tag
with tag content of[]byte
typeExpected: The code snippet should produce valid CBOR data
2(h'010000000000000000')
.Got: The code snippet produces invalid CBOR data
2(21(h'010000000000000000'))
.cc: @benluddy
EDIT: s/malformed/invalid
The text was updated successfully, but these errors were encountered: