Repository navigation
Fix CborReader exception handling for reserved simple-value headers - #135621
Merged
eiriktsarpalis merged 6 commits intoOct 14, 2026
Merged
eiriktsarpalis merged 6 commits into
eiriktsarpalis merged 6 commits into
Conversation
Preserve numeric conversion exceptions and document Unix-time range failures. Add coverage for skip APIs, reader rollback, and numeric boundaries. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-formats-cbor, @bartonjs, @vcsjones |
This was referenced Oct 12, 2026
bartonjs
reviewed
Oct 12, 2026
Translate DateTimeOffset conversion argument exceptions on the error path, preserving reader rollback and existing numeric overflow behavior. Cover single-precision overflow and strict map-key recovery. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
Translate both date-time argument range failures and numeric overflows in ReadUnixTimeSeconds as requested in review. Preserve the original exception as the inner cause, restore reader state, and keep validation off successful conversion paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
Replace the catch-all exception type test with separate ArgumentOutOfRangeException and OverflowException catch clauses, preserving reader rollback and InvalidOperationException wrapping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
Use an or pattern in the exception filter to share rollback and InvalidOperationException translation for argument range failures and numeric overflow. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
Restore the shared catch handler with an exception type check, preserving checkpoint rollback and InvalidOperationException translation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d9a0557-8d2c-459a-9c86-4f143c98b2a4
This was referenced Oct 13, 2026
Closed
bartonjs
reviewed
Oct 13, 2026
bartonjs
approved these changes
Oct 13, 2026
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.
Reserved additional-information values 28-30 are malformed CBOR, but
ReadSimpleValuereports their initial bytes (0xFC,0xFD,0xFE) asInvalidOperationException. The same exception escapes through the skip and encoded-value APIs. These inputs now throwCborContentException, including when conformance checks are disabled.The check is confined to the existing error branch. Valid floating-point encodings and container-end misuse retain
InvalidOperationException. Regression coverage includes nested values, incremental input, all conformance modes, and reader rollback. This is independent of the dangling-tag fix in #135359, with no changed-file overlap.ReadUnixTimeSecondsnow translates bothArgumentOutOfRangeExceptionandOverflowExceptionfrom numerical conversion toInvalidOperationExceptionwhen the encoded Unix time cannot be represented byDateTimeOffset. The original exception is preserved as the inner cause, and failures restore the reader checkpoint. The numerical operations are unchanged, with no success-path preflight checks. Tests cover numeric boundaries and recovery, including strict map-key validation.ReadDecimalretains its existingOverflowExceptionbehavior; well-formed out-of-range values are not reclassified as malformed CBOR.Note
This pull request was prepared with GitHub Copilot.