diff options
author | Christian Parpart <christian@parpart.family> | 2018-07-31 22:18:00 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-01 19:02:59 +0800 |
commit | 38f9667e090492d0581a5f1a14a48504242ca28e (patch) | |
tree | 27c2b3a9e4c77512331054a53c863a94efa3b58e /libsolidity/analysis | |
parent | ef269bf40d3c6fc044c27654473353c556402b77 (diff) | |
download | dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar.gz dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar.bz2 dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar.lz dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar.xz dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.tar.zst dexon-solidity-38f9667e090492d0581a5f1a14a48504242ca28e.zip |
Guard CycleDetector against recursion exhaustion.
fixes #3935.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/PostTypeChecker.cpp | 5 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 19d0b708..240d7973 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -91,8 +91,11 @@ bool PostTypeChecker::visit(Identifier const& _identifier) VariableDeclaration const* PostTypeChecker::findCycle(VariableDeclaration const& _startingFrom) { - auto visitor = [&](VariableDeclaration const& _variable, CycleDetector<VariableDeclaration>& _cycleDetector) + auto visitor = [&](VariableDeclaration const& _variable, CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth) { + if (_depth >= 256) + m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator."); + // Iterating through the dependencies needs to be deterministic and thus cannot // depend on the memory layout. // Because of that, we sort by AST node id. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d2fb9281..fdc7b434 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -595,8 +595,11 @@ bool TypeChecker::visit(StructDefinition const& _struct) m_errorReporter.typeError(member->location(), "Type cannot be used in struct."); // Check recursion, fatal error if detected. - auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector) + auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector, size_t _depth) { + if (_depth >= 256) + m_errorReporter.fatalDeclarationError(_struct.location(), "Struct definition exhausting cyclic dependency validator."); + for (ASTPointer<VariableDeclaration> const& member: _struct.members()) { Type const* memberType = type(*member).get(); |