6850783: InvalidityDateExtension returns reference to internal mutable state
authorxuelei
Tue, 16 Jun 2009 20:46:25 +0800
changeset 3045 cdfc2f549bbc
parent 2947 b0135c99348e
child 3046 dd50d75d88e6
6850783: InvalidityDateExtension returns reference to internal mutable state Summary: return cloned instead of referenced object Reviewed-by: weijun
jdk/src/share/classes/sun/security/x509/CertificateVersion.java
jdk/src/share/classes/sun/security/x509/InvalidityDateExtension.java
--- a/jdk/src/share/classes/sun/security/x509/CertificateVersion.java	Sun Jun 14 14:33:30 2009 -0700
+++ b/jdk/src/share/classes/sun/security/x509/CertificateVersion.java	Tue Jun 16 20:46:25 2009 +0800
@@ -28,7 +28,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Date;
 import java.util.Enumeration;
 
 import sun.security.util.*;
--- a/jdk/src/share/classes/sun/security/x509/InvalidityDateExtension.java	Sun Jun 14 14:33:30 2009 -0700
+++ b/jdk/src/share/classes/sun/security/x509/InvalidityDateExtension.java	Tue Jun 16 20:46:25 2009 +0800
@@ -140,7 +140,11 @@
      */
     public Object get(String name) throws IOException {
         if (name.equalsIgnoreCase(DATE)) {
-            return date;
+            if (date == null) {
+                return null;
+            } else {
+                return (new Date(date.getTime()));    // clone
+            }
         } else {
             throw new IOException
                 ("Name not supported by InvalidityDateExtension");