JDK-8226810: An other case and a small change suggestion

Johannes Kuhn info at j-kuhn.de
Sun May 10 14:47:46 UTC 2020


On 09-May-20 1:27, Brent Christian wrote:
> On 5/7/20 5:50 AM, Alan Bateman wrote:
>> On 07/05/2020 12:37, Johannes Kuhn wrote:
>>> :
>>>
>>> In the end, I don't know what causes the bug, or how I can replicate 
>>> it.
>>> I think I did find a likely suspect.
> >
>> Good sleuthing. I don't what the conditions are for GetLocaleInfo to 
>> fail but it does look like that would return possibly non-terminated 
>> garbage starting with "CP" so we should at least fix that.
>
> I agree.  I can file a bug and sponsor this small change.
>
> -Brent
Thank you.

After the discussion with Naoto, I would like to change the one line to 
strcpy(ret + 2, "1252")

diff --git a/src/java.base/windows/native/libjava/java_props_md.c 
b/src/java.base/windows/native/libjava/java_props_md.c
--- a/src/java.base/windows/native/libjava/java_props_md.c
+++ b/src/java.base/windows/native/libjava/java_props_md.c
@@ -73,6 +73,7 @@
                        LOCALE_IDEFAULTANSICODEPAGE,
                        ret+2, 14) == 0) {
          codepage = 1252;
+        strcpy(ret + 2, "1252");
      } else {
          codepage = atoi(ret+2);
      }

I have already signed the OCA.
This would be my first patch. Is there anything else you need?

I will take a further look into GetLocaleInfo, and try to find a model 
that works for me (currently thinking about blackbox, can return 
anything from [1]),
and then discussing how to handle all those cases.

- Johannes

[1]: 
https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers


More information about the core-libs-dev mailing list