Skip to content

Commit 31f7fc0

Browse files
jhuttanawangweij
authored andcommitted
8283082: sun.security.x509.X509CertImpl.delete("x509.info.validity") nulls out info field
Reviewed-by: weijun
1 parent d9ca438 commit 31f7fc0

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/java.base/share/classes/sun/security/x509/X509CertImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ public void delete(String name)
739739
id = attr.getPrefix();
740740

741741
if (id.equalsIgnoreCase(INFO)) {
742-
if (attr.getSuffix() != null) {
742+
if (attr.getSuffix() == null) {
743743
info = null;
744744
} else {
745745
info.delete(attr.getSuffix());
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2022, Red Hat, Inc.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8283082
27+
* @modules java.base/sun.security.x509
28+
* @summary This test is to confirm that
29+
* sun.security.x509.X509CertImpl.delete("x509.info.validity") doesn't
30+
* null out info field as reported by bug 8283082
31+
*/
32+
33+
import sun.security.x509.X500Name;
34+
import sun.security.x509.X509CertImpl;
35+
import sun.security.x509.X509CertInfo;
36+
37+
public class JDK8283082{
38+
public static void main(String[] args) throws Exception {
39+
var c = new X509CertImpl();
40+
c.set("x509.info", new X509CertInfo());
41+
c.set("x509.info.issuer", new X500Name("CN=one"));
42+
c.delete("x509.info.issuer");
43+
c.set("x509.info.issuer", new X500Name("CN=two"));
44+
}
45+
}

0 commit comments

Comments
 (0)