Skip to content

Commit

Permalink
fix ossl_x509_tbs_bytes error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed May 6, 2024
1 parent 562dfed commit 7453dfe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ext/openssl/ossl_x509cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,14 @@ ossl_x509_tbs_bytes(VALUE self)
GetX509(self, x509);
len = i2d_re_X509_tbs(x509, NULL);
if (len <= 0) {
ossl_raise(eX509CertError, NULL);
ossl_raise(eX509CertError, "i2d_re_X509_tbs");
}
str = rb_str_new(NULL, len);
p0 = p1 = (unsigned char *)RSTRING_PTR(str);
i2d_re_X509_tbs(x509, &p0);
assert(p0 - p1 == len);
if (i2d_re_X509_tbs(x509, &p0) <= 0) {
ossl_raise(eX509CertError, "i2d_re_X509_tbs");
}
ossl_str_adjust(str, p0);

return str;
}
Expand Down

0 comments on commit 7453dfe

Please sign in to comment.