Skip to content

Commit

Permalink
Fixed resource leak in OtherName.
Browse files Browse the repository at this point in the history
The OtherName has been modified to always close the
DerOutputStream instances.

https://fedorahosted.org/pki/ticket/2530
  • Loading branch information
edewata committed Nov 3, 2016
1 parent 4ce9c67 commit 7a66902
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions base/util/src/netscape/security/x509/OtherName.java
Expand Up @@ -60,20 +60,22 @@ public OtherName(DerValue derValue) throws IOException {
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();
}

/**
* 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 {
Expand All @@ -87,16 +89,20 @@ public OtherName(ObjectIdentifier oid, byte tag, String value) {
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();
}
Expand Down

0 comments on commit 7a66902

Please sign in to comment.