You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
接下来给一个样例(出自[Beware of the proxy: learn how to exploit function clashing - Security - OpenZeppelin Forum](https://forum.openzeppelin.com/t/beware-of-the-proxy-learn-how-to-exploit-function-clashing/1070)):
29
+
30
+
```solidity
31
+
pragma solidity ^0.5.0;
32
+
33
+
contract Proxy {
34
+
35
+
address public proxyOwner;
36
+
address public implementation;
37
+
38
+
constructor(address implementation) public {
39
+
proxyOwner = msg.sender;
40
+
_setImplementation(implementation);
41
+
}
42
+
43
+
modifier onlyProxyOwner() {
44
+
require(msg.sender == proxyOwner);
45
+
_;
46
+
}
47
+
48
+
function upgrade(address implementation) external onlyProxyOwner {
49
+
_setImplementation(implementation);
50
+
}
51
+
52
+
function _setImplementation(address imp) private {
53
+
implementation = imp;
54
+
}
55
+
56
+
function () payable external {
57
+
address impl = implementation;
58
+
59
+
assembly {
60
+
calldatacopy(0, 0, calldatasize)
61
+
let result := delegatecall(gas, impl, 0, calldatasize, 0, 0)
62
+
returndatacopy(0, 0, returndatasize)
63
+
64
+
switch result
65
+
case 0 { revert(0, returndatasize) }
66
+
default { return(0, returndatasize) }
67
+
}
68
+
}
69
+
70
+
// This is the function we're adding now
71
+
function collate_propagate_storage(bytes16) external {
0 commit comments