Skip to content

Commit cbcf0d2

Browse files
committed
prevents stack depth attack
1 parent a4f30af commit cbcf0d2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

swarm/services/chequebook/contract/chequebook.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ contract chequebook is mortal {
2727
if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return;
2828
// Attempt sending the difference between the cumulative amount on the cheque
2929
// and the cumulative amount on the last cashed cheque to beneficiary.
30-
if (beneficiary.send(amount - sent[beneficiary])) {
31-
// Upon success, update the cumulative amount.
32-
sent[beneficiary] = amount;
30+
if (amount - sent[beneficiary] >= this.balance) {
31+
if (beneficiary.send(amount - sent[beneficiary])) {
32+
// Upon success, update the cumulative amount.
33+
sent[beneficiary] = amount;
34+
}
3335
} else {
3436
// Upon failure, punish owner for writing a bounced cheque.
3537
// owner.sendToDebtorsPrison();

0 commit comments

Comments
 (0)