mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-23 09:29:05 +00:00
8358549: O(n²) time complexity in java.security.Provider.parseLegacy() method
Reviewed-by: mullan, djelinski
This commit is contained in:
parent
feb944c6c9
commit
f71c37bdb3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2026, 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
|
||||
@ -1084,9 +1084,16 @@ public abstract class Provider extends Properties {
|
||||
String stdAlg = attrString.substring(0, i).intern();
|
||||
String attrName = attrString.substring(i + 1);
|
||||
// kill additional spaces
|
||||
while (attrName.startsWith(" ")) {
|
||||
attrName = attrName.substring(1);
|
||||
int pos = 0;
|
||||
for (; pos < attrName.length(); pos++) {
|
||||
if (attrName.charAt(pos) != ' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos > 0) {
|
||||
attrName = attrName.substring(pos);
|
||||
}
|
||||
|
||||
attrName = attrName.intern();
|
||||
ServiceKey stdKey = new ServiceKey(type, stdAlg, true);
|
||||
Service stdService = legacyMap.get(stdKey);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2026, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4911081 8130181
|
||||
* @bug 4911081 8130181 8358549
|
||||
* @library /test/lib
|
||||
* @summary verify that Provider.Service.supportsParameter() works
|
||||
* @author Andreas Sterbenz
|
||||
@ -112,7 +112,9 @@ public class SupportsParameter {
|
||||
put("Signature.DSA0", "foo.DSA0");
|
||||
|
||||
put("Signature.DSA", "foo.DSA");
|
||||
put("Signature.DSA SupportedKeyClasses",
|
||||
// Extra spaces between "Signature.DSA" and "SupportedKeyClasses"
|
||||
// are used to verify that whitespace is trimmed.
|
||||
put("Signature.DSA SupportedKeyClasses",
|
||||
"java.security.interfaces.DSAPublicKey" +
|
||||
"|java.security.interfaces.DSAPrivateKey");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user