aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-06-30 02:12:46 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-07-05 23:55:09 +0800
commit811980afe6bc989473990281440e79aecf801472 (patch)
tree373c99cbf4cbf4b384d2d54c20923cbe14e29eb7 /docs
parent70e5af11ef3093fb16f05f3e281620c9c341fb1e (diff)
downloaddexon-solidity-811980afe6bc989473990281440e79aecf801472.tar
dexon-solidity-811980afe6bc989473990281440e79aecf801472.tar.gz
dexon-solidity-811980afe6bc989473990281440e79aecf801472.tar.bz2
dexon-solidity-811980afe6bc989473990281440e79aecf801472.tar.lz
dexon-solidity-811980afe6bc989473990281440e79aecf801472.tar.xz
dexon-solidity-811980afe6bc989473990281440e79aecf801472.tar.zst
dexon-solidity-811980afe6bc989473990281440e79aecf801472.zip
Reformat code
Diffstat (limited to 'docs')
-rw-r--r--docs/security-considerations.rst33
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