Merge pull request #2922 from colm/stackdepth_attack_checkbook

SWARM: prevents stack depth attack in checkbook.sol
This commit is contained in:
Viktor Trón 2016-08-19 19:28:08 +02:00 committed by GitHub
commit 8d94d68dea

View file

@ -27,9 +27,11 @@ contract chequebook is mortal {
if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return;
// Attempt sending the difference between the cumulative amount on the cheque
// and the cumulative amount on the last cashed cheque to beneficiary.
if (beneficiary.send(amount - sent[beneficiary])) {
// Upon success, update the cumulative amount.
sent[beneficiary] = amount;
if (amount - sent[beneficiary] >= this.balance) {
if (beneficiary.send(amount - sent[beneficiary])) {
// Upon success, update the cumulative amount.
sent[beneficiary] = amount;
}
} else {
// Upon failure, punish owner for writing a bounced cheque.
// owner.sendToDebtorsPrison();