diff options
author | Kazuki Yamaguchi <[email protected]> | 2025-01-07 02:14:50 +0900 |
---|---|---|
committer | git <[email protected]> | 2025-02-11 16:42:26 +0000 |
commit | 47cdf98fa43a481991c229532e74c44943efcf39 (patch) | |
tree | a4030ddb17c2ed553c4835a0a2fe868791b3751b | |
parent | 8888ad6902b0bb12bab0a1d16389e30f4916f413 (diff) |
[ruby/openssl] x509: do not check for negative return from X509_*_get_ext_count()
These functions wrap X509v3_get_ext_count(). The implementation can
never return a negative number, and this behavior is documented in the
man page.
https://github.com/ruby/openssl/commit/5164725855
-rw-r--r-- | ext/openssl/ossl_x509cert.c | 5 | ||||
-rw-r--r-- | ext/openssl/ossl_x509crl.c | 6 | ||||
-rw-r--r-- | ext/openssl/ossl_x509revoked.c | 6 |
3 files changed, 3 insertions, 14 deletions
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index 0505aac2af..62f4c5c24c 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -619,10 +619,7 @@ ossl_x509_get_extensions(VALUE self) GetX509(self, x509); count = X509_get_ext_count(x509); - if (count < 0) { - return rb_ary_new(); - } - ary = rb_ary_new2(count); + ary = rb_ary_new_capa(count); for (i=0; i<count; i++) { ext = X509_get_ext(x509, i); /* NO DUP - don't free! */ rb_ary_push(ary, ossl_x509ext_new(ext)); diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c index cfaf39640b..45b2546541 100644 --- a/ext/openssl/ossl_x509crl.c +++ b/ext/openssl/ossl_x509crl.c @@ -449,11 +449,7 @@ ossl_x509crl_get_extensions(VALUE self) GetX509CRL(self, crl); count = X509_CRL_get_ext_count(crl); - if (count < 0) { - OSSL_Debug("count < 0???"); - return rb_ary_new(); - } - ary = rb_ary_new2(count); + ary = rb_ary_new_capa(count); for (i=0; i<count; i++) { ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */ rb_ary_push(ary, ossl_x509ext_new(ext)); diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c index 7b9636449e..57aa79545a 100644 --- a/ext/openssl/ossl_x509revoked.c +++ b/ext/openssl/ossl_x509revoked.c @@ -194,11 +194,7 @@ ossl_x509revoked_get_extensions(VALUE self) GetX509Rev(self, rev); count = X509_REVOKED_get_ext_count(rev); - if (count < 0) { - OSSL_Debug("count < 0???"); - return rb_ary_new(); - } - ary = rb_ary_new2(count); + ary = rb_ary_new_capa(count); for (i=0; i<count; i++) { ext = X509_REVOKED_get_ext(rev, i); rb_ary_push(ary, ossl_x509ext_new(ext)); |