summaryrefslogtreecommitdiffstats
path: root/crypto/x509/t_x509.c
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2017-01-14 15:58:42 +0100
committerKurt Roeckx <kurt@roeckx.be>2017-01-15 22:21:07 +0100
commit244d7b288f2b9ab7f6a2dbf068eccd6e20d9eef6 (patch)
tree476fa2501861b47fe205a604b10a558d25ca857e /crypto/x509/t_x509.c
parenta470f02360b147fa73f94881ba96c367c593427f (diff)
Fix undefined behaviour when printing the X509 serial
Found by afl Reviewed-by: Andy Polyakov <appro@openssl.org> GH: #2230
Diffstat (limited to 'crypto/x509/t_x509.c')
-rw-r--r--crypto/x509/t_x509.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c
index ce670460ee..5119c0e6f7 100644
--- a/crypto/x509/t_x509.c
+++ b/crypto/x509/t_x509.c
@@ -93,12 +93,14 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
l = -1;
}
if (l != -1) {
+ unsigned long ul;
if (bs->type == V_ASN1_NEG_INTEGER) {
- l = -l;
+ ul = 0 - (unsigned long)l;
neg = "-";
} else
+ ul = l;
neg = "";
- if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, l, neg, l) <= 0)
+ if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, ul, neg, ul) <= 0)
goto err;
} else {
neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";