Skip to content

Commit a424aad

Browse files
committed
ts: fix exception class raised when getting an OID name
get_asn1obj() is used by several methods in OpenSSL::Timestamp to get the string representation of an OID. On an error, such as memory allocation failure, it can raise OpenSSL::X509::AttributeError. It should be OpenSSL::Timestamp::TimestampError instead.
1 parent b5f79f7 commit a424aad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/openssl/ossl_ts.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ get_asn1obj(ASN1_OBJECT *obj)
161161
ret = rb_str_new2(OBJ_nid2sn(nid));
162162
else{
163163
if (!(out = BIO_new(BIO_s_mem())))
164-
ossl_raise(eX509AttrError, NULL);
165-
i2a_ASN1_OBJECT(out, obj);
164+
ossl_raise(eTimestampError, "BIO_new(BIO_s_mem())");
165+
if (i2a_ASN1_OBJECT(out, obj) <= 0) {
166+
BIO_free(out);
167+
ossl_raise(eTimestampError, "i2a_ASN1_OBJECT");
168+
}
166169
ret = ossl_membio2str(out);
167170
}
168171

0 commit comments

Comments
 (0)