aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-15 08:54:08 +0800
committerGitHub <noreply@github.com>2017-08-15 08:54:08 +0800
commitdca1f45cb7a45a85a1a8206254de23342a870101 (patch)
tree62174ad9c87165682e1933173ce7c732d166b1f3 /test/libsolidity
parent892605e3c795fb1d54531585967ab9692754490e (diff)
parent32e43477c336c9180eedd6ad968595e33ecde704 (diff)
downloaddexon-solidity-dca1f45cb7a45a85a1a8206254de23342a870101.tar.gz
dexon-solidity-dca1f45cb7a45a85a1a8206254de23342a870101.tar.zst
dexon-solidity-dca1f45cb7a45a85a1a8206254de23342a870101.zip
Merge pull request #2743 from ethereum/preventStackOverflow
Prevent stack overflow due to recursion in parser
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityParser.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 75cad8d9..30dc80d9 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -1363,6 +1363,42 @@ BOOST_AUTO_TEST_CASE(conditional_with_assignment)
BOOST_CHECK(successParse(text));
}
+BOOST_AUTO_TEST_CASE(recursion_depth1)
+{
+ string text("contract C { bytes");
+ for (size_t i = 0; i < 30000; i++)
+ text += "[";
+ CHECK_PARSE_ERROR(text.c_str(), "Maximum recursion depth reached during parsing");
+}
+
+BOOST_AUTO_TEST_CASE(recursion_depth2)
+{
+ string text("contract C { function f() {");
+ for (size_t i = 0; i < 30000; i++)
+ text += "{";
+ CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing");
+}
+
+BOOST_AUTO_TEST_CASE(recursion_depth3)
+{
+ string text("contract C { function f() { uint x = f(");
+ for (size_t i = 0; i < 30000; i++)
+ text += "(";
+ CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing");
+}
+
+BOOST_AUTO_TEST_CASE(recursion_depth4)
+{
+ string text("contract C { function f() { uint a;");
+ for (size_t i = 0; i < 30000; i++)
+ text += "(";
+ text += "a";
+ for (size_t i = 0; i < 30000; i++)
+ text += "++)";
+ text += "}}";
+ CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing");
+}
+
BOOST_AUTO_TEST_CASE(declaring_fixed_and_ufixed_variables)
{
char const* text = R"(