Skip to content

Commit

Permalink
Replace an ASN1_INTEGER_get call with ASN1_INTEGER_get_uint64
Browse files Browse the repository at this point in the history
This gives clearer, less platform-dependent behavior.

Change-Id: Ib935bf861108ec010d8d409d840f94b52a3b3ae0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51635
Reviewed-by: Adam Langley <[email protected]>
Commit-Queue: David Benjamin <[email protected]>
  • Loading branch information
davidben authored and Boringssl LUCI CQ committed Mar 8, 2022
1 parent fdd5260 commit 6196fab
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crypto/x509/t_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
}

const ASN1_INTEGER *serial = X509_get0_serialNumber(x);
/* |ASN1_INTEGER_get| returns -1 on overflow, so this check skips
* negative and large serial numbers. */
l = ASN1_INTEGER_get(serial);
if (l >= 0) {
uint64_t serial_u64;
if (ASN1_INTEGER_get_uint64(&serial_u64, serial)) {
assert(serial->type != V_ASN1_NEG_INTEGER);
if (BIO_printf(bp, " %ld (0x%lx)\n", l, (unsigned long)l) <= 0) {
goto err;
if (BIO_printf(bp, " %" PRIu64 " (0x%" PRIx64 ")\n", serial_u64,
serial_u64) <= 0) {
goto err;
}
} else {
neg = (serial->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";
Expand Down

0 comments on commit 6196fab

Please sign in to comment.