diff options
author | chriseth <chris@ethereum.org> | 2017-08-15 00:58:56 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-08-15 00:58:56 +0800 |
commit | bcce31b548870c323747085676f118b5b46ed234 (patch) | |
tree | be987f51d1da237817cac2c36b2e37e0f7c7ebad /test/libsolidity | |
parent | 2411f5d839cd784ef31e076812787b2e1934ca9f (diff) | |
download | dexon-solidity-bcce31b548870c323747085676f118b5b46ed234.tar.gz dexon-solidity-bcce31b548870c323747085676f118b5b46ed234.tar.zst dexon-solidity-bcce31b548870c323747085676f118b5b46ed234.zip |
Tests for recursion exploit in parser.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 75cad8d9..23276fcd 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -1363,6 +1363,30 @@ 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(declaring_fixed_and_ufixed_variables) { char const* text = R"( |