-
Notifications
You must be signed in to change notification settings - Fork 1.8k
AVRO-4295: [csharp] Bound allocation when decoding length-prefixed values and collections #3860
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
Open
iemejia
wants to merge
21
commits into
apache:main
Choose a base branch
from
iemejia:AVRO-4295-csharp-available-bytes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2210a46
AVRO-4295: [csharp] Validate available bytes before allocating for le…
iemejia 04308d0
AVRO-4295: [csharp] Reject negative lengths and out-of-range counts; …
iemejia 7376905
AVRO-4295: [csharp] Use long for collection min-bytes to avoid int ov…
iemejia 4232c99
AVRO-4295: [csharp] Reject bytes length above the max .NET array length
iemejia 601f0ab
AVRO-4295: [csharp] Clamp RemainingBytes; reject negative counts; dee…
iemejia d200b5f
AVRO-4295: [csharp] Cap zero-byte collection element allocation
iemejia 99cefe0
AVRO-4295: [csharp] Reject long.MinValue array/map block count
iemejia 3671989
AVRO-4295: [csharp] Cast bounded length to int; clamp structural cap
iemejia 1af6c0a
AVRO-4295: [csharp] Clarify two doc comments
iemejia d308962
AVRO-4295: [csharp] Read string length as long to avoid int overflow
iemejia cf8a687
AVRO-4295: [csharp] Clamp structural cap to runtime max array length
iemejia 20fb487
AVRO-4295: [csharp] Grow array on demand instead of preallocating count
iemejia 6350b1e
AVRO-4295: [csharp] Explicitly bounds-check union and enum indices
iemejia 91609bd
AVRO-4295: [csharp] Reject overlong varints in ReadLong
iemejia 345a803
AVRO-4295: [csharp] Reject block-count overflow before adding to the …
iemejia ffecc24
AVRO-4295: [csharp] Clamp array growth to the structural cap
iemejia 8361138
AVRO-4295: [csharp] Reject malformed 10-byte varints in ReadLong
iemejia 98f8da0
AVRO-4295: [csharp] Compute prealloc in long; clarify structural-cap …
iemejia b5d6c69
AVRO-4295: [csharp] Isolate collection tests from AVRO_MAX_COLLECTION…
iemejia 22b8cac
AVRO-4295: [csharp] Revert ineffective env [SetUp]; document static caps
iemejia 6a9cb20
AVRO-4295: [csharp] Bound huge-count reject tests to just over the it…
iemejia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — this is a real gap specific to C#'s architecture:
PreresolvingDatumReader<T>(base of SpecificDatumReader/GenericDatumReader) is a separate reader implementation from the DefaultReader/GenericReader path hardened in this PR, so it doesn't inherit these checks (unlike Java, where SpecificDatumReader extends the hardened GenericDatumReader). Hardening it means sharing the limit logic, threading element min-bytes into ReadArray/ReadMap, clamping EnsureSize preallocation, and adding tests on the specific-reader path — a distinct change with its own regression risk on a widely-used path. Filed as AVRO-4306 (https://issues.apache.org/jira/browse/AVRO-4306) to do it properly with dedicated tests rather than bolt it onto this PR late in review.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct — PreresolvingDatumReader (the GenericDatumReader/SpecificDatumReader path) is not hardened by this PR. Tracked as a dedicated follow-up: AVRO-4306 ("Harden PreresolvingDatumReader collection allocation"). This PR intentionally scopes the DefaultReader/GenericReader path; AVRO-4306 will apply the same MinBytesPerElement/EnsureCollectionAvailable + bounded prealloc/grow to the preresolving path and add tests over GenericDatumReader/SpecificDatumReader.