diff options
author | Jim McDonald <Jim@mcdee.net> | 2017-12-13 02:47:30 +0800 |
---|---|---|
committer | Jim McDonald <Jim@mcdee.net> | 2017-12-13 02:47:30 +0800 |
commit | 6e521d59b0a30fa0673aaf84559d5b74dbb1eed7 (patch) | |
tree | 618b00999c2de8432f222c7b990f51ef4de6b1f0 /docs/security-considerations.rst | |
parent | 7614b16dc9b2bb1e267e8f46834b40220fb9f9fb (diff) | |
download | dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar.gz dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar.bz2 dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar.lz dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar.xz dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.tar.zst dexon-solidity-6e521d59b0a30fa0673aaf84559d5b74dbb1eed7.zip |
Fix Solidity warnings
Diffstat (limited to 'docs/security-considerations.rst')
-rw-r--r-- | docs/security-considerations.rst | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index 1e2138fa..49fd7ea4 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -62,7 +62,7 @@ complete contract): /// Mapping of ether shares of the contract. mapping(address => uint) shares; /// Withdraw your share. - function withdraw() { + function withdraw() public { if (msg.sender.send(shares[msg.sender])) shares[msg.sender] = 0; } @@ -85,7 +85,7 @@ as it uses ``call`` which forwards all remaining gas by default: /// Mapping of ether shares of the contract. mapping(address => uint) shares; /// Withdraw your share. - function withdraw() { + function withdraw() public { if (msg.sender.call.value(shares[msg.sender])()) shares[msg.sender] = 0; } @@ -102,7 +102,7 @@ outlined further below: /// Mapping of ether shares of the contract. mapping(address => uint) shares; /// Withdraw your share. - function withdraw() { + function withdraw() public { var share = shares[msg.sender]; shares[msg.sender] = 0; msg.sender.transfer(share); @@ -130,7 +130,7 @@ Sending and Receiving Ether - Neither contracts nor "external accounts" are currently able to prevent that someone sends them Ether. Contracts can react on and reject a regular transfer, but there are ways to move Ether without creating a message call. One way is to simply "mine to" - the contract address and the second way is using ``selfdestruct(x)``. + the contract address and the second way is using ``selfdestruct(x)``. - If a contract receives Ether (without a function being called), the fallback function is executed. If it does not have a fallback function, the Ether will be rejected (by throwing an exception). @@ -186,11 +186,11 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like contract TxUserWallet { address owner; - function TxUserWallet() { + function TxUserWallet() public { owner = msg.sender; } - function transferTo(address dest, uint amount) { + function transferTo(address dest, uint amount) public { require(tx.origin == owner); dest.transfer(amount); } @@ -203,17 +203,17 @@ Now someone tricks you into sending ether to the address of this attack wallet: pragma solidity ^0.4.11; interface TxUserWallet { - function transferTo(address dest, uint amount); + function transferTo(address dest, uint amount) public; } contract TxAttackWallet { address owner; - function TxAttackWallet() { + function TxAttackWallet() public { owner = msg.sender; } - function() { + function() public { TxUserWallet(msg.sender).transferTo(owner, msg.sender.balance); } } |