mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
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
This commit is contained in:
parent
866e505e0d
commit
e80f3b6af2
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user