From 266b1c3056d5679cd08aef314befed9cb2775344 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sun, 11 Mar 2018 22:11:42 +0700 Subject: [PATCH] avoid overwrite of target function --- contracts/deploy/DelegatedCall.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/deploy/DelegatedCall.sol b/contracts/deploy/DelegatedCall.sol index 8f42dea..0526c76 100644 --- a/contracts/deploy/DelegatedCall.sol +++ b/contracts/deploy/DelegatedCall.sol @@ -4,7 +4,8 @@ pragma solidity ^0.4.17; /** * @title DelegatedCall * @author Ricardo Guilherme Schmidt (Status Research & Development GmbH) - * @dev Abstract contract that delegates calls by `delegated` modifier to result of `_target()` + * @dev Abstract contract that delegates calls by `delegated` modifier to result of `targetDelegatedCall()` + * Important to avoid overwriting wrong storage pointers is that never define storage to this contract */ contract DelegatedCall { /** @@ -12,20 +13,21 @@ contract DelegatedCall { */ modifier delegated { //require successfull delegate call to remote `_target()` - require(_target().delegatecall(msg.data)); + require(targetDelegatedCall().delegatecall(msg.data)); assembly { let outSize := returndatasize let outDataPtr := mload(0x40) //load memory returndatacopy(outDataPtr, 0, outSize) //copy last return into pointer return(outDataPtr, outSize) } + assert(false); //should never reach here _; //never will execute local logic } /** * @dev defines the address for delegation of calls */ - function _target() + function targetDelegatedCall() internal constant returns(address);