summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKazuki Yamaguchi <[email protected]>2024-10-30 03:59:03 +0900
committergit <[email protected]>2024-12-07 07:55:46 +0000
commitcbe7bfd9a81273c04a40f1ff19f516f8db31ac53 (patch)
tree1c15b2e23fb53b74fd8910388535eaf0286f5295 /ext
parentf8e9302e66e336d4e174182ebebc6a05a47ac28b (diff)
[ruby/openssl] 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. https://github.com/ruby/openssl/commit/a424aad1df
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_ts.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index dadbc38f98..bcd1777a78 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -161,8 +161,11 @@ get_asn1obj(ASN1_OBJECT *obj)
ret = rb_str_new2(OBJ_nid2sn(nid));
else{
if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509AttrError, NULL);
- i2a_ASN1_OBJECT(out, obj);
+ ossl_raise(eTimestampError, "BIO_new(BIO_s_mem())");
+ if (i2a_ASN1_OBJECT(out, obj) <= 0) {
+ BIO_free(out);
+ ossl_raise(eTimestampError, "i2a_ASN1_OBJECT");
+ }
ret = ossl_membio2str(out);
}