summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_x509req.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2022-09-02 13:55:19 +0900
committerKazuki Yamaguchi <k@rhe.jp>2022-10-17 16:35:35 +0900
commitbee383d9fe84eb29ec12a8c392fcbf7c646575b8 (patch)
treec14856c9793e9833606ec66f736b4ed527fd7585 /ext/openssl/ossl_x509req.c
parent79543b9a530d85f0487583d96ad412f5e7683ffa (diff)
[ruby/openssl] x509*: fix error queue leak in #extensions= and #attributes= methods
X509at_delete_attr() in OpenSSL master puts an error queue entry if there is no attribute left to delete. We must either clear the error queue, or try not to call it when the list is already empty. https://github.com/ruby/openssl/commit/a0c878481f
Diffstat (limited to 'ext/openssl/ossl_x509req.c')
-rw-r--r--ext/openssl/ossl_x509req.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 6eb91e9c2f..77a7d3f2ff 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -380,13 +380,13 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
}
GetX509Req(self, req);
- while ((attr = X509_REQ_delete_attr(req, 0)))
- X509_ATTRIBUTE_free(attr);
+ for (i = X509_REQ_get_attr_count(req); i > 0; i--)
+ X509_ATTRIBUTE_free(X509_REQ_delete_attr(req, 0));
for (i=0;i<RARRAY_LEN(ary); i++) {
item = RARRAY_AREF(ary, i);
attr = GetX509AttrPtr(item);
if (!X509_REQ_add1_attr(req, attr)) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, "X509_REQ_add1_attr");
}
}
return ary;