summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2016-07-17 15:28:09 +0200
committerRichard Levitte <levitte@openssl.org>2017-03-20 22:10:54 +0100
commite5afec1831248c767be7c5844a88535dabecc01a (patch)
tree592a4a7ea1a392b473c90c66e6568947a557f40b /crypto/asn1
parent2cbd4d98673d99cd7cb10715656b6d3727342e77 (diff)
Cast to an unsigned type before negating
llvm's ubsan reported: runtime error: negation of -9223372036854775808 cannot be represented in type 'long'; cast to an unsigned type to negate this value to itself Found using afl Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1325 (cherry picked from commit 1618679ac478c8f41fc5f320fb4d8a33883b3868)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/x_long.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/asn1/x_long.c b/crypto/asn1/x_long.c
index 98562a18ba..efdf574e24 100644
--- a/crypto/asn1/x_long.c
+++ b/crypto/asn1/x_long.c
@@ -126,7 +126,7 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
* set.
*/
if (ltmp < 0)
- utmp = -ltmp - 1;
+ utmp = -(unsigned long)ltmp - 1;
else
utmp = ltmp;
clen = BN_num_bits_word(utmp);