-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVMScripts: check byte lengths, avoid returning unallocated memory, a…
…nd forward error data (#496)
- Loading branch information
Showing
13 changed files
with
845 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../../apps/AragonApp.sol"; | ||
|
||
|
||
contract AppStubScriptRunner is AragonApp { | ||
event ReturnedBytes(bytes returnedBytes); | ||
|
||
// Initialization is required to access any of the real executors | ||
function initialize() public { | ||
initialized(); | ||
} | ||
|
||
function runScript(bytes script) public returns (bytes) { | ||
bytes memory returnedBytes = runScript(script, new bytes(0), new address[](0)); | ||
emit ReturnedBytes(returnedBytes); | ||
return returnedBytes; | ||
} | ||
|
||
function runScriptWithBan(bytes script, address[] memory blacklist) public returns (bytes) { | ||
bytes memory returnedBytes = runScript(script, new bytes(0), blacklist); | ||
emit ReturnedBytes(returnedBytes); | ||
return returnedBytes; | ||
} | ||
|
||
function runScriptWithIO(bytes script, bytes input, address[] memory blacklist) public returns (bytes) { | ||
bytes memory returnedBytes = runScript(script, input, blacklist); | ||
emit ReturnedBytes(returnedBytes); | ||
return returnedBytes; | ||
} | ||
|
||
function runScriptWithNewBytesAllocation(bytes script) public returns (bytes) { | ||
bytes memory returnedBytes = runScript(script, new bytes(0), new address[](0)); | ||
bytes memory newBytes = new bytes(64); | ||
|
||
// Fill in new bytes array with some dummy data to let us check it doesn't corrupt the | ||
// script's returned bytes | ||
uint256 first = uint256(keccak256("test")); | ||
uint256 second = uint256(keccak256("mock")); | ||
assembly { | ||
mstore(add(newBytes, 0x20), first) | ||
mstore(add(newBytes, 0x40), second) | ||
} | ||
emit ReturnedBytes(returnedBytes); | ||
return returnedBytes; | ||
} | ||
|
||
/* | ||
function getActionsCount(bytes script) public constant returns (uint256) { | ||
return getScriptActionsCount(script); | ||
} | ||
function getAction(bytes script, uint256 i) public constant returns (address, bytes) { | ||
return getScriptAction(script, i); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma solidity 0.4.24; | ||
|
||
|
||
import "../../evmscript/executors/BaseEVMScriptExecutor.sol"; | ||
|
||
contract EVMScriptExecutorRevertMock is BaseEVMScriptExecutor { | ||
string public constant ERROR_MOCK_REVERT = "MOCK_REVERT"; | ||
bytes32 internal constant EXECUTOR_TYPE = keccak256("MOCK_REVERT_SCRIPT"); | ||
|
||
function execScript(bytes, bytes, address[]) external isInitialized returns (bytes) { | ||
revert(ERROR_MOCK_REVERT); | ||
} | ||
|
||
function executorType() external pure returns (bytes32) { | ||
return EXECUTOR_TYPE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.