Skip to content

Commit

Permalink
Check ASN1_INTEGER_get for errors.
Browse files Browse the repository at this point in the history
Check return value when calling ASN1_INTEGER_get to retrieve a certificate
serial number. If an error occurs (which will be caused by the value being
out of range) revert to hex dump of serial number.

Reviewed-by: Rich Salz <[email protected]>
  • Loading branch information
snhenson committed Jun 6, 2015
1 parent c0cf5b8 commit 4336de0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crypto/asn1/t_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,

bs = X509_get_serialNumber(x);
if (bs->length <= (int)sizeof(long)) {
l = ASN1_INTEGER_get(bs);
ERR_set_mark();
l = ASN1_INTEGER_get(bs);
ERR_pop_to_mark();
} else {
l = -1;
}
if (l != -1) {
if (bs->type == V_ASN1_NEG_INTEGER) {
l = -l;
neg = "-";
Expand Down

0 comments on commit 4336de0

Please sign in to comment.