diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java index e1eb96f035..65b14fe295 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java @@ -54,8 +54,7 @@ public class CallFOperation extends AbstractOperation { int section = code.readBigEndianU16(pc + 1); CodeSection info = code.getCodeSection(section); int operandStackSize = frame.stackSize(); - if (operandStackSize >= 1024 - || operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { + if (operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { return callfStackOverflow; } frame.getReturnStack().push(new ReturnStack.ReturnStackItem(frame.getSection(), pc + 2)); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java index c76caa9667..bda66546d5 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.evm.Code; import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.evm.gascalculator.GasCalculator; @@ -28,6 +29,9 @@ public class JumpFOperation extends AbstractOperation { /** The Jump F success operation result. */ static final OperationResult jumpfSuccess = new OperationResult(5, null); + static final OperationResult jumpfStackOverflow = + new OperationResult(5, ExceptionalHaltReason.TOO_MANY_STACK_ITEMS); + /** * Instantiates a new Jump F operation. * @@ -46,6 +50,10 @@ public class JumpFOperation extends AbstractOperation { int pc = frame.getPC(); int section = code.readBigEndianU16(pc + 1); var info = code.getCodeSection(section); + int operandStackSize = frame.stackSize(); + if (operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { + return jumpfStackOverflow; + } frame.setPC(info.getEntryPoint() - 1); // will be +1ed at end of operations loop frame.setSection(section); return jumpfSuccess;