The OtherName has been modified to always close the
DerOutputStream instances.

https://fedorahosted.org/pki/ticket/2530

Pushed to master under trivial/one-liner rule.

--
Endi S. Dewata
>From 7a66902bfba413ffee5d05f89297e0bf9c0c39eb Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <[email protected]>
Date: Thu, 3 Nov 2016 02:40:41 +0100
Subject: [PATCH] Fixed resource leak in OtherName.

The OtherName has been modified to always close the
DerOutputStream instances.

https://fedorahosted.org/pki/ticket/2530
---
 base/util/src/netscape/security/x509/OtherName.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/base/util/src/netscape/security/x509/OtherName.java b/base/util/src/netscape/security/x509/OtherName.java
index ae8398344b08d434296e5136f2f0d5565fda5d3d..a78c4fa7ad05bd3836f060a0ea8152330905df1f 100644
--- a/base/util/src/netscape/security/x509/OtherName.java
+++ b/base/util/src/netscape/security/x509/OtherName.java
@@ -60,12 +60,14 @@ public class OtherName implements GeneralNameInterface {
         decodeThis(derValue);
     }
 
-    public OtherName(ObjectIdentifier oid, byte data[]) {
+    public OtherName(ObjectIdentifier oid, byte data[]) throws IOException {
         mOID = oid;
         DerOutputStream dos = new DerOutputStream();
         try {
             dos.putDerValue(new DerValue(data));
         } catch (IOException e) {
+        } finally {
+            dos.close();
         }
         mData = dos.toByteArray();
     }
@@ -73,7 +75,7 @@ public class OtherName implements GeneralNameInterface {
     /**
      * Constructs a string-based other name.
      */
-    public OtherName(ObjectIdentifier oid, byte tag, String value) {
+    public OtherName(ObjectIdentifier oid, byte tag, String value) throws IOException {
         mOID = oid;
         DerOutputStream dos = new DerOutputStream();
         try {
@@ -87,16 +89,20 @@ public class OtherName implements GeneralNameInterface {
                 dos.putUTF8String(value);
             }
         } catch (IOException e) {
+        } finally {
+            dos.close();
         }
         mData = dos.toByteArray();
     }
 
-    public OtherName(ObjectIdentifier oid, String value) {
+    public OtherName(ObjectIdentifier oid, String value) throws IOException {
         mOID = oid;
         DerOutputStream dos = new DerOutputStream();
         try {
             dos.putPrintableString(value);
         } catch (IOException e) {
+        } finally {
+            dos.close();
         }
         mData = dos.toByteArray();
     }
-- 
2.5.5

_______________________________________________
Pki-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to