File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
test/tools/yulInterpreter Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,9 @@ void ExpressionEvaluator::runExternalCall(evmasm::Instruction _instruction)
461
461
InterpreterState tmpState;
462
462
tmpState.calldata = m_state.readMemory (memInOffset, memInSize);
463
463
tmpState.callvalue = callvalue;
464
+ tmpState.numInstance = m_state.numInstance + 1 ;
465
+
466
+ yulAssert (tmpState.numInstance < 1024 , " Detected more than 1024 recursive calls, aborting..." );
464
467
465
468
// Create new interpreter for the called contract
466
469
unique_ptr<Interpreter> newInterpreter = makeInterpreterNew (tmpState, tmpScope);
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ struct InterpreterState
107
107
size_t maxExprNesting = 0 ;
108
108
ControlFlowState controlFlowState = ControlFlowState::Default;
109
109
110
+ // / Number of the current state instance, used for recursion protection
111
+ size_t numInstance = 0 ;
112
+
110
113
// / Prints execution trace and non-zero storage to @param _out.
111
114
// / Flag @param _disableMemoryTrace, if set, does not produce a memory dump. This
112
115
// / avoids false positives reports by the fuzzer when certain optimizer steps are
You can’t perform that action at this time.
0 commit comments