Repository navigation
Validate string SerDe bounds before allocation - #783
Draft
jaideeppyne wants to merge 1 commit into
Draft
jaideeppyne wants to merge 1 commit into
jaideeppyne wants to merge 1 commit into
Conversation
leerho
marked this pull request as draft
October 29, 2026 20:41
Member
|
Thanks for this, @jaideeppyne — the fix and tests look good. We’re holding it briefly so we can merge it together with related work going into the 9.1.0 release, and we’ve marked it as a draft so it isn’t merged early. No changes are needed from you. We’ll follow up when it’s ready to merge. |
Member
|
Note to Reviewers: Please go ahead and review this PR even though it is in Draft. See my note to the author above. |
leerho
approved these changes
Oct 29, 2026
This branch has not been deployed
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.
Problem
The UTF-8 and UTF-16 string SerDes allocate arrays from serialized counts and length prefixes before checking that the input segment contains those bytes. Invalid input can therefore throw
NegativeArraySizeExceptionorOutOfMemoryErrorinstead of the expected bounds exception.Change
Check the minimum prefix space before allocating the output array, and validate each string's payload before allocating its byte buffer. Valid serialized bytes and zero-item behavior are unchanged.
The new tests exercise both SerDes with impossible item counts, negative and oversized length prefixes, truncated prefixes, invalid offsets, and offset Unicode/empty-string round trips. They also verify that decoded strings remain independent of later input mutations.
Verification
Tests-first and full verification on JDK 25:
NegativeArraySizeExceptionandOutOfMemoryErrorpaths.mvn -B clean verify: 2,305 tests passed, no failures, errors, or skips.Source:
628ac813eb143c287ed9da5594e74f5222fc29be. No dependencies or serialization formats changed.Prepared with OpenAI Codex assistance, including implementation and tests.