提交 2917e2a5 编写于 作者: X xuelei

6867345: Turkish regional options cause NPE in sun.security.x509.AlgorithmId.algOID

Reviewed-by: mullan, weijun
上级 13dd38c4
...@@ -36,6 +36,7 @@ import sun.security.krb5.internal.ccache.CredentialsCache; ...@@ -36,6 +36,7 @@ import sun.security.krb5.internal.ccache.CredentialsCache;
import sun.security.krb5.internal.crypto.EType; import sun.security.krb5.internal.crypto.EType;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import java.net.InetAddress; import java.net.InetAddress;
/** /**
...@@ -287,7 +288,7 @@ public class Credentials { ...@@ -287,7 +288,7 @@ public class Credentials {
// The default ticket cache on Windows is not a file. // The default ticket cache on Windows is not a file.
String os = java.security.AccessController.doPrivileged( String os = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("os.name")); new sun.security.action.GetPropertyAction("os.name"));
if (os.toUpperCase().startsWith("WINDOWS")) { if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS")) {
Credentials creds = acquireDefaultCreds(); Credentials creds = acquireDefaultCreds();
if (creds == null) { if (creds == null) {
if (DEBUG) { if (DEBUG) {
......
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,6 +28,7 @@ package sun.security.pkcs; ...@@ -28,6 +28,7 @@ package sun.security.pkcs;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.Locale;
import java.util.Date; import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import sun.security.x509.CertificateExtensions; import sun.security.x509.CertificateExtensions;
...@@ -742,7 +743,7 @@ public class PKCS9Attribute implements DerEncoder { ...@@ -742,7 +743,7 @@ public class PKCS9Attribute implements DerEncoder {
* the name. * the name.
*/ */
public static ObjectIdentifier getOID(String name) { public static ObjectIdentifier getOID(String name) {
return NAME_OID_TABLE.get(name.toLowerCase()); return NAME_OID_TABLE.get(name.toLowerCase(Locale.ENGLISH));
} }
/** /**
......
...@@ -26,6 +26,7 @@ package sun.security.pkcs11; ...@@ -26,6 +26,7 @@ package sun.security.pkcs11;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import java.security.*; import java.security.*;
import java.security.spec.*; import java.security.spec.*;
...@@ -201,7 +202,7 @@ final class P11Cipher extends CipherSpi { ...@@ -201,7 +202,7 @@ final class P11Cipher extends CipherSpi {
} }
private int parseMode(String mode) throws NoSuchAlgorithmException { private int parseMode(String mode) throws NoSuchAlgorithmException {
mode = mode.toUpperCase(); mode = mode.toUpperCase(Locale.ENGLISH);
int result; int result;
if (mode.equals("ECB")) { if (mode.equals("ECB")) {
result = MODE_ECB; result = MODE_ECB;
...@@ -222,7 +223,7 @@ final class P11Cipher extends CipherSpi { ...@@ -222,7 +223,7 @@ final class P11Cipher extends CipherSpi {
throws NoSuchPaddingException { throws NoSuchPaddingException {
paddingObj = null; paddingObj = null;
padBuffer = null; padBuffer = null;
padding = padding.toUpperCase(); padding = padding.toUpperCase(Locale.ENGLISH);
if (padding.equals("NOPADDING")) { if (padding.equals("NOPADDING")) {
paddingType = PAD_NONE; paddingType = PAD_NONE;
} else if (padding.equals("PKCS5PADDING")) { } else if (padding.equals("PKCS5PADDING")) {
......
...@@ -29,6 +29,8 @@ import java.security.*; ...@@ -29,6 +29,8 @@ import java.security.*;
import java.security.spec.AlgorithmParameterSpec; import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.*; import java.security.spec.*;
import java.util.Locale;
import javax.crypto.*; import javax.crypto.*;
import javax.crypto.spec.*; import javax.crypto.spec.*;
...@@ -110,7 +112,7 @@ final class P11RSACipher extends CipherSpi { ...@@ -110,7 +112,7 @@ final class P11RSACipher extends CipherSpi {
protected void engineSetPadding(String padding) protected void engineSetPadding(String padding)
throws NoSuchPaddingException { throws NoSuchPaddingException {
String lowerPadding = padding.toLowerCase(); String lowerPadding = padding.toLowerCase(Locale.ENGLISH);
if (lowerPadding.equals("pkcs1Padding")) { if (lowerPadding.equals("pkcs1Padding")) {
// empty // empty
} else { } else {
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -52,6 +52,7 @@ import java.util.ArrayList; ...@@ -52,6 +52,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import sun.security.x509.AccessDescription; import sun.security.x509.AccessDescription;
import sun.security.x509.GeneralNameInterface; import sun.security.x509.GeneralNameInterface;
import sun.security.x509.URIName; import sun.security.x509.URIName;
...@@ -162,7 +163,7 @@ class URICertStore extends CertStoreSpi { ...@@ -162,7 +163,7 @@ class URICertStore extends CertStoreSpi {
} }
this.uri = ((URICertStoreParameters) params).uri; this.uri = ((URICertStoreParameters) params).uri;
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs // if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase().equals("ldap")) { if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
if (LDAP.helper() == null) if (LDAP.helper() == null)
throw new NoSuchAlgorithmException("LDAP not present"); throw new NoSuchAlgorithmException("LDAP not present");
ldap = true; ldap = true;
......
/* /*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,6 +28,7 @@ package sun.security.util; ...@@ -28,6 +28,7 @@ package sun.security.util;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.Locale;
/** /**
* A utility class for debuging. * A utility class for debuging.
...@@ -262,7 +263,7 @@ public class Debug { ...@@ -262,7 +263,7 @@ public class Debug {
source = left; source = left;
// convert the rest to lower-case characters // convert the rest to lower-case characters
target.append(source.toString().toLowerCase()); target.append(source.toString().toLowerCase(Locale.ENGLISH));
return target.toString(); return target.toString();
} }
......
/* /*
* Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1227,7 +1227,7 @@ class AVAKeyword { ...@@ -1227,7 +1227,7 @@ class AVAKeyword {
(String keyword, int standard, Map<String, String> extraKeywordMap) (String keyword, int standard, Map<String, String> extraKeywordMap)
throws IOException { throws IOException {
keyword = keyword.toUpperCase(); keyword = keyword.toUpperCase(Locale.ENGLISH);
if (standard == AVA.RFC2253) { if (standard == AVA.RFC2253) {
if (keyword.startsWith(" ") || keyword.endsWith(" ")) { if (keyword.startsWith(" ") || keyword.endsWith(" ")) {
throw new IOException("Invalid leading or trailing space " + throw new IOException("Invalid leading or trailing space " +
......
/* /*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -553,9 +553,10 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -553,9 +553,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
for (Enumeration<Object> enum_ = provs[i].keys(); for (Enumeration<Object> enum_ = provs[i].keys();
enum_.hasMoreElements(); ) { enum_.hasMoreElements(); ) {
String alias = (String)enum_.nextElement(); String alias = (String)enum_.nextElement();
String upperCaseAlias = alias.toUpperCase(Locale.ENGLISH);
int index; int index;
if (alias.toUpperCase().startsWith("ALG.ALIAS") && if (upperCaseAlias.startsWith("ALG.ALIAS") &&
(index=alias.toUpperCase().indexOf("OID.", 0)) != -1) { (index=upperCaseAlias.indexOf("OID.", 0)) != -1) {
index += "OID.".length(); index += "OID.".length();
if (index == alias.length()) { if (index == alias.length()) {
// invalid alias entry // invalid alias entry
...@@ -565,19 +566,26 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -565,19 +566,26 @@ public class AlgorithmId implements Serializable, DerEncoder {
oidTable = new HashMap<String,ObjectIdentifier>(); oidTable = new HashMap<String,ObjectIdentifier>();
} }
oidString = alias.substring(index); oidString = alias.substring(index);
String stdAlgName String stdAlgName = provs[i].getProperty(alias);
= provs[i].getProperty(alias).toUpperCase(); if (stdAlgName != null) {
if (oidTable.get(stdAlgName) == null) { stdAlgName = stdAlgName.toUpperCase(Locale.ENGLISH);
}
if (stdAlgName != null &&
oidTable.get(stdAlgName) == null) {
oidTable.put(stdAlgName, oidTable.put(stdAlgName,
new ObjectIdentifier(oidString)); new ObjectIdentifier(oidString));
} }
} }
} }
} }
if (oidTable == null) {
oidTable = new HashMap<String,ObjectIdentifier>(1);
}
initOidTable = true; initOidTable = true;
} }
return oidTable.get(name.toUpperCase()); return oidTable.get(name.toUpperCase(Locale.ENGLISH));
} }
private static ObjectIdentifier oid(int ... values) { private static ObjectIdentifier oid(int ... values) {
......
/* /*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package sun.security.x509; package sun.security.x509;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
import sun.security.util.*; import sun.security.util.*;
...@@ -198,8 +199,9 @@ public class DNSName implements GeneralNameInterface { ...@@ -198,8 +199,9 @@ public class DNSName implements GeneralNameInterface {
else if (inputName.getType() != NAME_DNS) else if (inputName.getType() != NAME_DNS)
constraintType = NAME_DIFF_TYPE; constraintType = NAME_DIFF_TYPE;
else { else {
String inName = (((DNSName)inputName).getName()).toLowerCase(); String inName =
String thisName = name.toLowerCase(); (((DNSName)inputName).getName()).toLowerCase(Locale.ENGLISH);
String thisName = name.toLowerCase(Locale.ENGLISH);
if (inName.equals(thisName)) if (inName.equals(thisName))
constraintType = NAME_MATCH; constraintType = NAME_MATCH;
else if (thisName.endsWith(inName)) { else if (thisName.endsWith(inName)) {
......
/* /*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package sun.security.x509; package sun.security.x509;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
import sun.security.util.*; import sun.security.util.*;
...@@ -187,8 +188,9 @@ public class RFC822Name implements GeneralNameInterface ...@@ -187,8 +188,9 @@ public class RFC822Name implements GeneralNameInterface
constraintType = NAME_DIFF_TYPE; constraintType = NAME_DIFF_TYPE;
} else { } else {
//RFC2459 specifies that case is not significant in RFC822Names //RFC2459 specifies that case is not significant in RFC822Names
String inName = (((RFC822Name)inputName).getName()).toLowerCase(); String inName =
String thisName = name.toLowerCase(); (((RFC822Name)inputName).getName()).toLowerCase(Locale.ENGLISH);
String thisName = name.toLowerCase(Locale.ENGLISH);
if (inName.equals(thisName)) { if (inName.equals(thisName)) {
constraintType = NAME_MATCH; constraintType = NAME_MATCH;
} else if (thisName.endsWith(inName)) { } else if (thisName.endsWith(inName)) {
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6867345
* @summary Turkish regional options cause NPE in
* sun.security.x509.AlgorithmId.algOID
* @run main/othervm -Duser.language=tr -Duser.region=TR TurkishRegion
* @author Xuelei Fan
*/
import sun.security.x509.*;
public class TurkishRegion {
public static void main(String[] args) throws Exception {
AlgorithmId algId = AlgorithmId.get("PBEWITHMD5ANDDES");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册