RFR: 8300038: Make new version of JNU_GetStringPlatformChars which checks for null characters [v3]

Alan Bateman alanb at openjdk.org
Wed May 24 14:33:00 UTC 2023


On Wed, 24 May 2023 10:14:23 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> This PR creates a new version of the JNI utility function JNU_GetStringPlatformChars called JNU_GetStringPlatformCharsStrict, which performs additional validation of the returned string, namely that it does not contain any embedded NULL characters. If any such characters are found the function returns NULL with an IAE pending. The change also switches usage in the networking native code to use the new function.
>> 
>> This cautious approach was taken rather than changing the behavior of the existing function as each native code area needs to review the effect of making the switch. Otherwise, surprising behavior changes might occur (eg undocumented IAE being thrown to user code instead of some other exception).
>
> Michael McMahon has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
> 
>  - Merge branch 'master' into nullStrings
>  - test comment update
>  - test update
>  - Merge branch 'master' into nullStrings
>  - exception message update
>  - test update
>  - remve whitespace
>  - update
>  - Merge branch 'master' into nullStrings
>  - first impl

I skimmed through the changes and mostly look okay. There's a few usage of "NULL" in exception messages that I assume should be "NUL character".  Probably need to bump the copyright date on several files.  You might want to find a better name for the test as NullChar isn't too descriptive, the test is really doing a lookup of a hostname that contains a NUL character. I assume there will be follow up issues to change other parts of the system to use the strict functions.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14083#issuecomment-1561271438


More information about the core-libs-dev mailing list