From 811980afe6bc989473990281440e79aecf801472 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 29 Jun 2016 14:12:46 -0400 Subject: Reformat code --- docs/security-considerations.rst | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'docs/security-considerations.rst') 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 -- cgit