Skip to content

Commit 4e8f331

Browse files
author
John Jiang
committedJul 20, 2023
8312443: sun.security should use toLowerCase(Locale.ROOT)
Reviewed-by: xuelei
1 parent d7b9416 commit 4e8f331

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed
 

‎src/java.base/share/classes/sun/security/action/GetPropertyAction.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import java.security.AccessController;
2929
import java.security.PrivilegedAction;
30+
import java.util.Locale;
3031
import java.util.Properties;
3132
import sun.security.util.Debug;
3233

@@ -194,10 +195,10 @@ public static int privilegedGetTimeoutProp(String prop, int def, Debug dbg) {
194195
// the original value in rawPropVal for debug messages.
195196
boolean isMillis = false;
196197
String propVal = rawPropVal;
197-
if (rawPropVal.toLowerCase().endsWith("ms")) {
198+
if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("ms")) {
198199
propVal = rawPropVal.substring(0, rawPropVal.length() - 2);
199200
isMillis = true;
200-
} else if (rawPropVal.toLowerCase().endsWith("s")) {
201+
} else if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("s")) {
201202
propVal = rawPropVal.substring(0, rawPropVal.length() - 1);
202203
}
203204

‎src/java.base/share/classes/sun/security/ec/ParametersMap.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
3131
import java.security.spec.AlgorithmParameterSpec;
3232
import java.security.spec.NamedParameterSpec;
3333
import java.util.Collections;
34+
import java.util.Locale;
3435
import java.util.Map;
3536
import java.util.HashMap;
3637
import java.util.Optional;
@@ -53,7 +54,7 @@ public void fix() {
5354
}
5455

5556
public void put(String name, ObjectIdentifier oid, int size, T params) {
56-
nameMap.put(name.toLowerCase(), params);
57+
nameMap.put(name.toLowerCase(Locale.ROOT), params);
5758
oidMap.put(oid, params);
5859
sizeMap.put(size, params);
5960
}
@@ -65,7 +66,7 @@ public Optional<T> getBySize(int size) {
6566
return Optional.ofNullable(sizeMap.get(size));
6667
}
6768
public Optional<T> getByName(String name) {
68-
return Optional.ofNullable(nameMap.get(name.toLowerCase()));
69+
return Optional.ofNullable(nameMap.get(name.toLowerCase(Locale.ROOT)));
6970
}
7071

7172
// Utility method that is used by the methods below to handle exception

‎src/java.base/share/classes/sun/security/ec/XECParameters.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private static XECParameters addParameters(int bits, BigInteger p, int a24,
137137
ObjectIdentifier oid = ObjectIdentifier.of(koid);
138138
XECParameters params =
139139
new XECParameters(bits, p, a24, basePoint, logCofactor, oid, name);
140-
namedParams.put(name.toLowerCase(), oid, bits, params);
140+
namedParams.put(name, oid, bits, params);
141141
return params;
142142
}
143143

@@ -170,4 +170,3 @@ XECParameters get(Function<String, T> exception,
170170
return namedParams.get(exception, params);
171171
}
172172
}
173-

0 commit comments

Comments
 (0)
Please sign in to comment.