summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2016-11-11 21:41:50 +0100
committerKurt Roeckx <kurt@roeckx.be>2016-11-12 14:09:20 +0100
commitfadfc8ecfd277af189600648fcf1d28f33fd76fe (patch)
treef807bf35ba6208fc8b6145b25b4b4cd81190087d /crypto/asn1
parent0f251d20a5c40cb9b6d30dfec005bb4ead3d5b0f (diff)
Cast to an unsigned type before negating
llvm's ubsan reported: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself Found using libfuzzer Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1908 (cherry picked from commit e80f3b6af295133107ac709329eee16ccf9af61c)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/a_int.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index 36248df92d..833322e89b 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -289,7 +289,7 @@ static int asn1_get_int64(int64_t *pr, const unsigned char *b, size_t blen,
ASN1err(ASN1_F_ASN1_GET_INT64, ASN1_R_TOO_SMALL);
return 0;
}
- *pr = -(int64_t)r;
+ *pr = -(uint64_t)r;
} else {
if (r > INT64_MAX) {
ASN1err(ASN1_F_ASN1_GET_INT64, ASN1_R_TOO_LARGE);