Skip to content

Commit

Permalink
Merge pull request #755 from rhenium/ky/asn1-check-i2d-error
Browse files Browse the repository at this point in the history
asn1: check error return from i2d_ASN1_TYPE()
  • Loading branch information
rhenium committed May 2, 2024
2 parents 5a52368 + 21ed3c3 commit abacf2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ext/openssl/ossl_asn1.c
Expand Up @@ -1163,9 +1163,12 @@ ossl_asn1prim_to_der(VALUE self)
rb_jump_tag(state);
}
p0 = p1 = (unsigned char *)RSTRING_PTR(str);
i2d_ASN1_TYPE(asn1, &p0);
if (i2d_ASN1_TYPE(asn1, &p0) < 0) {
ASN1_TYPE_free(asn1);
ossl_raise(eASN1Error, "i2d_ASN1_TYPE");
}
ASN1_TYPE_free(asn1);
assert(p0 - p1 == alllen);
ossl_str_adjust(str, p0);

/* Strip header since to_der_internal() wants only the payload */
j = ASN1_get_object((const unsigned char **)&p1, &bodylen, &tag, &tc, alllen);
Expand Down

0 comments on commit abacf2f

Please sign in to comment.