yulRun: Add recursion protection

This commit is contained in:
Marenz 2022-09-13 14:05:50 +02:00
parent d10d967008
commit 692a99f891
2 changed files with 6 additions and 0 deletions

View File

@ -461,6 +461,9 @@ void ExpressionEvaluator::runExternalCall(evmasm::Instruction _instruction)
InterpreterState tmpState;
tmpState.calldata = m_state.readMemory(memInOffset, memInSize);
tmpState.callvalue = callvalue;
tmpState.numInstance = m_state.numInstance + 1;
yulAssert(tmpState.numInstance < 1024, "Detected more than 1024 recursive calls, aborting...");
// Create new interpreter for the called contract
unique_ptr<Interpreter> newInterpreter = makeInterpreterNew(tmpState, tmpScope);

View File

@ -107,6 +107,9 @@ struct InterpreterState
size_t maxExprNesting = 0;
ControlFlowState controlFlowState = ControlFlowState::Default;
/// Number of the current state instance, used for recursion protection
size_t numInstance = 0;
/// Prints execution trace and non-zero storage to @param _out.
/// Flag @param _disableMemoryTrace, if set, does not produce a memory dump. This
/// avoids false positives reports by the fuzzer when certain optimizer steps are