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
This commit is contained in:
parent
69588edbaa
commit
1618679ac4
2 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -451,7 +451,7 @@ fmtint(char **sbuffer,
|
|||
if (!(flags & DP_F_UNSIGNED)) {
|
||||
if (value < 0) {
|
||||
signvalue = '-';
|
||||
uvalue = -value;
|
||||
uvalue = -(unsigned LLONG)value;
|
||||
} else if (flags & DP_F_PLUS)
|
||||
signvalue = '+';
|
||||
else if (flags & DP_F_SPACE)
|
||||
|
|
Loading…
Reference in a new issue