From bee383d9fe84eb29ec12a8c392fcbf7c646575b8 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Fri, 2 Sep 2022 13:55:19 +0900 Subject: [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 --- ext/openssl/ossl_x509cert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/openssl/ossl_x509cert.c') diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index 996f184170..9443541645 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -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