write overflow check nicer (#6215)

This commit is contained in:
Christian Grothoff 2020-04-23 12:02:52 +02:00
parent 0774fd7020
commit c79a95c7d2
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -126,7 +126,8 @@ TALER_string_to_amount (const char *str,
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
n = *value - '0'; n = *value - '0';
if ( (amount->value * 10 + n < amount->value) || if ( (amount->value * 10 < amount->value) ||
(amount->value * 10 + n < amount->value) ||
(amount->value > MAX_AMOUNT_VALUE) ) (amount->value > MAX_AMOUNT_VALUE) )
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,