-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1209 from luna2163/main
feat: fix reentrancy contract code
- Loading branch information
Showing
7 changed files
with
142 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.7; | ||
|
||
|
||
import "./IVault.sol"; | ||
import "hardhat/console.sol"; | ||
|
||
|
||
contract BuggyVault is IVault { | ||
mapping(address => uint256) public balances; | ||
|
||
mapping(address=>uint256) public balances; | ||
|
||
function deposit() external override payable{ | ||
function deposit() external override payable { | ||
balances[msg.sender] += msg.value; | ||
} | ||
|
||
function withdraw() external override{ | ||
function withdraw() external override { | ||
address payable target = payable(msg.sender); | ||
|
||
(bool success,) = target.call{value:balances[msg.sender]}(""); | ||
console.log(success); | ||
balances[msg.sender] = 0; | ||
|
||
balances[msg.sender] = 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.7; | ||
|
||
interface IVault { | ||
|
||
function deposit() external payable ; | ||
|
||
function deposit() external payable; | ||
function withdraw() external; | ||
} | ||
} |
Oops, something went wrong.