Skip data item when decoding to time.Time fails under certain conditions - #803
Merged
Merged
Conversation
NOTE: This issue does not affect standard CBOR time data (RFC 8949 tag 0 or tag 1) because the decoder already skips those data items on error. Setting timeTag = DecTagRequired also avoids the issue. When decoding into time.Time from a CBOR byte string, map, or array and decoding fails with UnmarshalTypeError, the data item at the cursor is not skipped under these decoding options: - CBOR byte string, if byteStringToTime == ByteStringToTimeForbidden and timeTag != DecTagRequired - CBOR array and map, if timeTag != DecTagRequired Since the cursor is not advanced, a caller can encounter unrelated decoding errors or panic if they continue parsing the rest of the CBOR data. This commit resolves the issue by skipping the data item under the above conditions, making it consistent with the other options and data types when decoding to time.Time.
Owner
Author
|
@x448 PTAL 🙏 I updated fuzz tests to check for this issue and it passed limited fuzzing today with this PR (I will continue fuzzing v2.9.3 after release tagging). |
x448
approved these changes
Aug 18, 2026
x448
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I only reviewed non-test code.
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.
Refs #802
NOTE: This issue does not affect standard CBOR time data (RFC 8949 tag 0 or tag 1) because the decoder already skips those data items on error. Setting
timeTag=DecTagRequiredalso avoids the issue.When decoding into
time.Timefrom a CBOR byte string, map, or array and decoding fails withUnmarshalTypeError, the data item at the cursor is not skipped under these decoding options:byteStringToTime == ByteStringToTimeForbiddenandtimeTag != DecTagRequiredtimeTag != DecTagRequiredSince the cursor is not advanced, a caller can encounter unrelated decoding errors or panic if they continue parsing the rest of the CBOR data.
This problem was identified while trying to reproduce the stack trace mentioned in issue #802.
This PR resolves the issue by skipping the data item under the above conditions, making it consistent with the other options and data types when decoding to time.Time.