aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1/x_long.c
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2016-07-17 15:28:09 +0200
committerKurt Roeckx <kurt@roeckx.be>2016-07-20 19:25:16 +0200
commit1618679ac478c8f41fc5f320fb4d8a33883b3868 (patch)
tree226153f11e35f97136574bdaaec6ce6dc5f745ec /crypto/asn1/x_long.c
parent69588edbaa424beb71c6a9b1be416588232cb78c (diff)
downloadopenssl-1618679ac478c8f41fc5f320fb4d8a33883b3868.zip
openssl-1618679ac478c8f41fc5f320fb4d8a33883b3868.tar.gz
openssl-1618679ac478c8f41fc5f320fb4d8a33883b3868.tar.bz2
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
Diffstat (limited to 'crypto/asn1/x_long.c')
-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 0af7875..e86e4c7 100644
--- a/crypto/asn1/x_long.c
+++ b/crypto/asn1/x_long.c
@@ -76,7 +76,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);