aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCJentzsch <jentzsch.software@gmail.com>2014-12-05 00:55:04 +0800
committerCJentzsch <jentzsch.software@gmail.com>2014-12-05 00:55:04 +0800
commitb7601aee9fdc1d72f65938a035f52aa77146bcf4 (patch)
treee913b52b4686d41d95aeced759529bebfcfb0066
parent3c8a45cec4a36ebd4560d7f4ee718b60680b3010 (diff)
downloaddexon-solidity-b7601aee9fdc1d72f65938a035f52aa77146bcf4.tar.gz
dexon-solidity-b7601aee9fdc1d72f65938a035f52aa77146bcf4.tar.zst
dexon-solidity-b7601aee9fdc1d72f65938a035f52aa77146bcf4.zip
fix stackoverflow in calldataload, codecopy, extcodecopy + some tests
-rw-r--r--stPreCompiledContractsFiller.json35
-rw-r--r--vm.cpp20
-rw-r--r--vmEnvironmentalInfoTestFiller.json140
3 files changed, 195 insertions, 0 deletions
diff --git a/stPreCompiledContractsFiller.json b/stPreCompiledContractsFiller.json
index 9c65ad37..62a3a162 100644
--- a/stPreCompiledContractsFiller.json
+++ b/stPreCompiledContractsFiller.json
@@ -33,6 +33,41 @@
}
},
+ "CallEcrecover0_overlappingInputOutput": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "10000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "20000000",
+ "nonce" : 0,
+ "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 1000 1 0 0 128 64 32) [[ 0 ]] (MOD (MLOAD 64) (EXP 2 160)) [[ 1 ]] (EQ (ORIGIN) (SLOAD 0)) }",
+ "storage": {}
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "365224",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+
"CallEcrecover0_completeReturnValue": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
diff --git a/vm.cpp b/vm.cpp
index d7bc0612..e674d6de 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -488,6 +488,26 @@ BOOST_AUTO_TEST_CASE(vmLogTest)
dev::test::executeTests("vmLogTest", "/VMTests", dev::test::doVMTests);
}
+BOOST_AUTO_TEST_CASE(vmPerformanceTest)
+{
+ for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
+ {
+ string arg = boost::unit_test::framework::master_test_suite().argv[i];
+ if (arg == "--performance")
+ dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(vmArithPerformanceTest)
+{
+ for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
+ {
+ string arg = boost::unit_test::framework::master_test_suite().argv[i];
+ if (arg == "--performance")
+ dev::test::executeTests("vmArithPerformanceTest", "/VMTests", dev::test::doVMTests);
+ }
+}
+
BOOST_AUTO_TEST_CASE(vmRandom)
{
string testPath = getTestPath();
diff --git a/vmEnvironmentalInfoTestFiller.json b/vmEnvironmentalInfoTestFiller.json
index 95e7936a..abeed994 100644
--- a/vmEnvironmentalInfoTestFiller.json
+++ b/vmEnvironmentalInfoTestFiller.json
@@ -338,6 +338,33 @@
}
},
+ "calldataloadSizeTooHigh": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (CALLDATALOAD 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa)}",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "0x123456789abcdef0000000000000000000000000000000000000000000000000024",
+ "gasPrice" : "1000000000",
+ "gas" : "100000000000"
+ }
+ },
"calldatasize0": {
"env" : {
@@ -451,6 +478,62 @@
}
},
+ "calldatacopy_DataIndexTooHigh": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 0xff ) [[ 0 ]] @0}",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "0x1234567890abcdef01234567890abcdef",
+ "gasPrice" : "1000000000",
+ "gas" : "100000000000"
+ }
+ },
+
+ "calldatacopy_DataIndexTooHigh2": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 9 ) [[ 0 ]] @0}",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "0x1234567890abcdef01234567890abcdef",
+ "gasPrice" : "1000000000",
+ "gas" : "100000000000"
+ }
+ },
+
"calldatacopy1": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@@ -535,6 +618,34 @@
}
},
+ "codecopy_DataIndexTooHigh": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ (CODECOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "0x1234567890abcdef01234567890abcdef",
+ "gasPrice" : "1000000000",
+ "gas" : "100000000000"
+ }
+ },
+
"codecopy0": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@@ -686,6 +797,35 @@
}
},
+ "extcodecopy_DataIndexTooHigh": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ (EXTCODECOPY (ADDRESS) 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "0x1234567890abcdef01234567890abcdef",
+ "gasPrice" : "1000000000",
+ "gas" : "100000000000"
+ }
+ },
+
+
"extcodecopy0": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",