mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
This commit is contained in:
parent
79543b9a53
commit
bee383d9fe
4 changed files with 12 additions and 12 deletions
|
@ -642,12 +642,12 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
|
|||
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
||||
}
|
||||
GetX509(self, x509);
|
||||
while ((ext = X509_delete_ext(x509, 0)))
|
||||
X509_EXTENSION_free(ext);
|
||||
for (i = X509_get_ext_count(x509); i > 0; i--)
|
||||
X509_EXTENSION_free(X509_delete_ext(x509, 0));
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
ext = GetX509ExtPtr(RARRAY_AREF(ary, i));
|
||||
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext */
|
||||
ossl_raise(eX509CertError, NULL);
|
||||
ossl_raise(eX509CertError, "X509_add_ext");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -474,12 +474,12 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
|
|||
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
||||
}
|
||||
GetX509CRL(self, crl);
|
||||
while ((ext = X509_CRL_delete_ext(crl, 0)))
|
||||
X509_EXTENSION_free(ext);
|
||||
for (i = X509_CRL_get_ext_count(crl); i > 0; i--)
|
||||
X509_EXTENSION_free(X509_CRL_delete_ext(crl, 0));
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
ext = GetX509ExtPtr(RARRAY_AREF(ary, i)); /* NO NEED TO DUP */
|
||||
if (!X509_CRL_add_ext(crl, ext, -1)) {
|
||||
ossl_raise(eX509CRLError, NULL);
|
||||
ossl_raise(eX509CRLError, "X509_CRL_add_ext");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -223,13 +223,13 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
|
|||
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
||||
}
|
||||
GetX509Rev(self, rev);
|
||||
while ((ext = X509_REVOKED_delete_ext(rev, 0)))
|
||||
X509_EXTENSION_free(ext);
|
||||
for (i = X509_REVOKED_get_ext_count(rev); i > 0; i--)
|
||||
X509_EXTENSION_free(X509_REVOKED_delete_ext(rev, 0));
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
item = RARRAY_AREF(ary, i);
|
||||
ext = GetX509ExtPtr(item);
|
||||
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
|
||||
ossl_raise(eX509RevError, NULL);
|
||||
ossl_raise(eX509RevError, "X509_REVOKED_add_ext");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue