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 panic when decoding CBOR nil to *cbor.SimpleValue #461

Merged
merged 1 commit into from
Jan 1, 2024

Conversation

fxamacker
Copy link
Owner

Closes #460

Unmarshalling CBOR nil or CBOR undefined into a Go pointer should always set the pointer to nil.

This PR:

  • fixes panic when unmarshalling CBOR nil or CBOR undefined into *cbor.SimpleValue by setting the pointer to nil.
  • adds more tests for decoding to uninitialized and initialized pointer values.

Separately (not part of this PR), the fuzzer was updated to attempt unmarshaling directly to *cbor.SimpleValue.

@fxamacker fxamacker added this to the v2.6.0 milestone Jan 1, 2024
@fxamacker fxamacker force-pushed the fxamacker/fix-decode-cbor-null-to-pointer branch 2 times, most recently from 4a2755d to 942d6a1 Compare January 1, 2024 20:55
decode.go Outdated Show resolved Hide resolved
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.

Great catch!

Given this fixes a decoder panic, are you going to release v2.5.1 or v2.6.0 with this fix soon?

How long was this fix fuzz tested in case we want to use it in production before next release tag?

Unmarshalling CBOR nil or CBOR undefined into a Go pointer should
always set the pointer to nil.

This commit fixes crash bug when unmarshalling CBOR nil or CBOR
undefined into *cbor.SimpleValue by setting the pointer to nil.

Also, added more tests for decoding to uninitialized and initialized
pointer values.

Separately (not part of this commit), the fuzzer was updated to
attempt unmarshaling to *cbor.SimpleValue.
@fxamacker fxamacker force-pushed the fxamacker/fix-decode-cbor-null-to-pointer branch from 942d6a1 to cdc043a Compare January 1, 2024 21:49
@fxamacker
Copy link
Owner Author

@x448

Given this fixes a decoder panic, are you going to release v2.5.1 or v2.6.0 with this fix soon?

Probably v2.6.0 because they are new features merged and fuzzed already.

How long was this fix fuzz tested in case we want to use it in production before next release tag?

It's best to wait for release tag before deploying to production, but feel free to try using main branch anytime for tests, etc.

BTW, I have at least 1 more bugfix to merge before tagging.

@fxamacker fxamacker merged commit 95e432d into master Jan 1, 2024
17 checks passed
@fxamacker fxamacker deleted the fxamacker/fix-decode-cbor-null-to-pointer 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: updated fuzzing detected panic while decoding CBOR nil or CBOR undefined to *cbor.SimpleValue
2 participants