diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/security-considerations.rst | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index a96e58e9..726b8a2a 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -50,13 +50,13 @@ complete contract): // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract Fund { - /// Mapping of ether shares of the contract. - mapping(address => uint) shares; - /// Withdraw your share. - function withdraw() { - if (msg.sender.send(shares[msg.sender])) - shares[msg.sender] = 0; - } + /// Mapping of ether shares of the contract. + mapping(address => uint) shares; + /// Withdraw your share. + function withdraw() { + if (msg.sender.send(shares[msg.sender])) + shares[msg.sender] = 0; + } } The problem is not too serious here because of the limited gas as part @@ -71,18 +71,17 @@ outlined further below: :: contract Fund { - /// Mapping of ether shares of the contract. - mapping(address => uint) shares; - /// Withdraw your share. - function withdraw() { - var share = shares[msg.sender]; - shares[msg.sender] = 0; - if (!msg.sender.send(share)) - throw; - } + /// Mapping of ether shares of the contract. + mapping(address => uint) shares; + /// Withdraw your share. + function withdraw() { + var share = shares[msg.sender]; + shares[msg.sender] = 0; + if (!msg.sender.send(share)) + throw; + } } - Note that re-entrancy is not only an effect of Ether transfer but of any function call on another contract. Furthermore, you also have to take multi-contract situations into account. A called contract could modify the |