Skip to content

Port PR 803 to master branch - #804

Merged
fxamacker merged 1 commit into
masterfrom
fxamacker/port-pr-803-to-master
Aug 18, 2026
Merged

Port PR 803 to master branch#804
fxamacker merged 1 commit into
masterfrom
fxamacker/port-pr-803-to-master

Conversation

@fxamacker

@fxamacker fxamacker commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Port PR #803 (from v2.9.3) to master branch.

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.
@fxamacker fxamacker self-assigned this Aug 18, 2026

@x448 x448 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks for the same-day fix!

@fxamacker
fxamacker merged commit eb8c23e into master Aug 18, 2026
16 checks passed
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.

2 participants