pool:rpc_on_wallet_transferred: check underflow

Check against balance integer underflow in rpc_on_wallet_transferred.
This commit is contained in:
Michael Contreras 2020-05-05 23:27:59 -04:00 committed by Jethro Grassie
parent 047aef644c
commit 66507021e0
No known key found for this signature in database
GPG Key ID: DE8ED755616565BB
1 changed files with 12 additions and 1 deletions

View File

@ -1953,7 +1953,18 @@ rpc_on_wallet_transferred(const char* data, rpc_callback_t *callback)
continue;
}
uint64_t current_amount = *(uint64_t*)val.mv_data;
current_amount -= payment->amount;
if (current_amount >= payment->amount)
{
current_amount -= payment->amount;
}
else
{
log_error("Payment was more than balance: %"PRIu64" > %"PRIu64,
payment->amount, current_amount);
current_amount = 0;
}
if (error)
{
log_warn("Error seen on transfer for %s with amount %"PRIu64,