Skip to content
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

(0.48) Fix overflow issues #20363

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

babsingh
Copy link
Contributor

@babsingh babsingh commented Oct 16, 2024

Backport of #20362

Background

See https://bugs.openjdk.org/browse/JDK-8338709 and https://bugs.openjdk.org/browse/JDK-8328877.

Implementation

Truncate length while evaluating length of a UTF-8 string

  • On 32-bit systems, the length is truncated to UDATA_MAX.
  • For JNI getStringUTFLength, the length is truncated to INT32_MAX.

Add restrictions while copying a string to UTF-8 to avoid overflow

  • The length is restricted to UDATA_MAX to accommodate memory allocation
    functions, which take a UDATA as the input parameter for length.
  • The data is stopped from being written to the UTF-8 buffer if its
    length will be exceeded.

Signed-off-by: Babneet Singh [email protected]

Truncate length while evaluating length of a UTF-8 string

- On 32-bit systems, the length is truncated to UDATA_MAX.
- For JNI getStringUTFLength, the length is truncated to INT32_MAX.

Add restrictions while copying a string to UTF-8 to avoid overflow

- The length is restricted to UDATA_MAX to accommodate memory allocation
functions, which take a UDATA as the input parameter for length.
- The data is stopped from being written to the UTF-8 buffer if its
length will be exceeded.

Signed-off-by: Babneet Singh <[email protected]>
@pshipton pshipton requested review from keithc-ca and removed request for pshipton October 16, 2024 15:17
@keithc-ca keithc-ca self-assigned this Oct 16, 2024
@keithc-ca keithc-ca merged commit 4604b04 into eclipse-openj9:v0.48.0-release Oct 16, 2024
2 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.

3 participants