从稳健性文档中,我不明白最近引入的address.transfer是将所有气体转发给目标合同,还是只给出最低限度的气体津贴。它会促进重新进入攻击吗?
发布于 2017-05-07 22:13:21
试一试再找出来?
contract TestInterface {
function reentrance(address dest);
}
contract Test is TestInterface {
uint8 private _depth = 0;
// make it payable
function () payable {}
event Entered(uint8 depth);
function reentrance(address dest) {
if (_depth > 2) {
// yep
throw;
}
Entered(_depth);
_depth++;
dest.transfer(this.balance);
}
}
contract Destination {
function () payable {
TestInterface sender = TestInterface(msg.sender);
// send it back so we can do it again.
msg.sender.send(this.balance);
sender.reentrance(this);
}
}
// deploy Test
// send Test some ETH
// Deploy Destination
// call Test.reentrance with Destination's address
// Watch for events from Testhttps://ethereum.stackexchange.com/questions/15928
复制相似问题