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

8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters #344

Closed
wants to merge 2 commits into from

Conversation

amosshi
Copy link

@amosshi amosshi commented Mar 8, 2024

Backport of JDK-8320570

  • NegativeSize.java - Clean backport
  • String.java - only 1 line change is unclean, the rest are clean. Details as bellow.
  • This PR contains 2 commits
    • The commit 1: is a clean backport part
    • The commit 2: is a manual fix of the following 1 line:
      • In the jdk master branch, the variable name is utf16
      • Well in jdk21u-dev, the varialbe name is buf
      • So we manully applied the following line
@@ -592,7 +592,7 @@
                     this.coder = LATIN1;
                     return;
                 }
-                byte[] utf16 = new byte[length << 1];
+                byte[] utf16 = StringUTF16.newBytesFor(length);
                 StringLatin1.inflate(latin1, 0, utf16, 0, dp);
                 dp = decodeUTF8_UTF16(latin1, sp, length, utf16, dp, true);
                 if (dp != length) {
  • So this PR can be considered as semantics clean

Testing

  • Local: Passed on MacOS M1 laptop
    • test/jdk/java/lang/String/CompactString/NegativeSize.java - Test results: passed: 1
  • Pipeline:
  • Testing Machine:

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8320570 needs maintainer approval

Issue

  • JDK-8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters (Bug - P3 - Approved)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/344/head:pull/344
$ git checkout pull/344

Update a local copy of the PR:
$ git checkout pull/344
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/344/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 344

View PR using the GUI difftool:
$ git pr show -t 344

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/344.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 8, 2024

👋 Welcome back ashi! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title Backport 82796bdebbf56b98ec97a6d572ed68c2842f60c6 8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters Mar 8, 2024
@openjdk
Copy link

openjdk bot commented Mar 8, 2024

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport approval rfr Pull request is ready for review labels Mar 8, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 8, 2024

Webrevs

@openjdk openjdk bot removed the approval label Mar 11, 2024
@phohensee
Copy link
Member

This PR duplicates #332. Please close it.

@amosshi amosshi closed this Mar 13, 2024
@amosshi amosshi deleted the backport-8320570 branch March 13, 2024 01:40
@amosshi amosshi restored the backport-8320570 branch April 9, 2024 18:27
@amosshi amosshi deleted the backport-8320570 branch April 9, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport rfr Pull request is ready for review
2 participants