Skip to content

Commit 0773649

Browse files
blperez01bohendo
authored andcommitted
Update list_dos.sol
fixed `send` vs `transfer` issues
1 parent e93176f commit 0773649

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

denial_of_service/list_dos.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contract CrowdFundBad {
66

77
function refundDos() public {
88
for(uint i; i < refundAddresses.length; i++) {
9-
require(refundAddresses[i].send(refundAmount[refundAddresses[i]]));
9+
require(refundAddresses[i].transfer(refundAmount[refundAddresses[i]]));
1010
}
1111
}
1212
}
@@ -18,14 +18,13 @@ contract CrowdFundPull {
1818
function withdraw() external {
1919
uint refund = refundAmount[msg.sender];
2020
refundAmount[msg.sender] = 0;
21-
msg.sender.send(refund);
21+
msg.sender.transfer(refund);
2222
}
2323
}
2424

2525

26-
//This is safe against the list length being the source of block gas limit issues
27-
//but is not safe in the scenario where the payee takes up a lot of gas, or is that
28-
// not possible because send has a fixed gas limit?
26+
//This is safe against the list length causing out of gas issues
27+
//but is not safe against the payee causing the execution to revert
2928
contract CrowdFundSafe {
3029
address[] private refundAddresses;
3130
mapping(address => uint) public refundAmount;
@@ -34,7 +33,7 @@ contract CrowdFundSafe {
3433
function refundSafe() public {
3534
uint256 i = nextIdx;
3635
while(i < refundAddresses.length && msg.gas > 200000) {
37-
refundAddresses[i].send(refundAmount[i]);
36+
refundAddresses[i].transfer(refundAmount[i]);
3837
i++;
3938
}
4039
nextIdx = i;

0 commit comments

Comments
 (0)