Skip to content

Commit bb3c532

Browse files
committed
x509: do not check for negative return from X509_*_get_ext_count()
These functions are wrappers of X509v3_get_ext_count(). The implementation can never return a negative number, and this behavior is documented in the man page.
1 parent a059817 commit bb3c532

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

ext/openssl/ossl_x509cert.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,7 @@ ossl_x509_get_extensions(VALUE self)
617617

618618
GetX509(self, x509);
619619
count = X509_get_ext_count(x509);
620-
if (count < 0) {
621-
return rb_ary_new();
622-
}
623-
ary = rb_ary_new2(count);
620+
ary = rb_ary_new_capa(count);
624621
for (i=0; i<count; i++) {
625622
ext = X509_get_ext(x509, i); /* NO DUP - don't free! */
626623
rb_ary_push(ary, ossl_x509ext_new(ext));

ext/openssl/ossl_x509crl.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,7 @@ ossl_x509crl_get_extensions(VALUE self)
447447

448448
GetX509CRL(self, crl);
449449
count = X509_CRL_get_ext_count(crl);
450-
if (count < 0) {
451-
OSSL_Debug("count < 0???");
452-
return rb_ary_new();
453-
}
454-
ary = rb_ary_new2(count);
450+
ary = rb_ary_new_capa(count);
455451
for (i=0; i<count; i++) {
456452
ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */
457453
rb_ary_push(ary, ossl_x509ext_new(ext));

ext/openssl/ossl_x509revoked.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,7 @@ ossl_x509revoked_get_extensions(VALUE self)
194194

195195
GetX509Rev(self, rev);
196196
count = X509_REVOKED_get_ext_count(rev);
197-
if (count < 0) {
198-
OSSL_Debug("count < 0???");
199-
return rb_ary_new();
200-
}
201-
ary = rb_ary_new2(count);
197+
ary = rb_ary_new_capa(count);
202198
for (i=0; i<count; i++) {
203199
ext = X509_REVOKED_get_ext(rev, i);
204200
rb_ary_push(ary, ossl_x509ext_new(ext));

0 commit comments

Comments
 (0)