提交 42d42b58 编写于 作者: X xuelei

6862064: incorrect implementation of PKIXParameters.clone()

Reviewed-by: weijun, mullan
上级 f76ac514
/* /*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2009 Sun Microsystems, Inc. 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
...@@ -663,15 +663,23 @@ public class PKIXParameters implements CertPathParameters { ...@@ -663,15 +663,23 @@ public class PKIXParameters implements CertPathParameters {
*/ */
public Object clone() { public Object clone() {
try { try {
Object copy = super.clone(); PKIXParameters copy = (PKIXParameters)super.clone();
// Must clone these because addCertStore, et al. modify them
// must clone these because addCertStore, et al. modify them
if (certStores != null) { if (certStores != null) {
certStores = new ArrayList<CertStore>(certStores); copy.certStores = new ArrayList<CertStore>(certStores);
} }
if (certPathCheckers != null) { if (certPathCheckers != null) {
certPathCheckers = copy.certPathCheckers =
new ArrayList<PKIXCertPathChecker>(certPathCheckers); new ArrayList<PKIXCertPathChecker>(certPathCheckers.size());
for (PKIXCertPathChecker checker : certPathCheckers) {
copy.certPathCheckers.add(
(PKIXCertPathChecker)checker.clone());
}
} }
// other class fields are immutable to public, don't bother
// to clone the read-only fields.
return copy; return copy;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
/* Cannot happen */ /* Cannot happen */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册