From 03dbc0a2100c1d62e9523a03bd892c66f7b49e63 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 22 Nov 2021 22:22:04 +0100 Subject: [PATCH] fix boundary condition check in PUSH32 --- core/vm/instructions.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 6902536758d5..fdc6e3a37c27 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -964,8 +964,10 @@ func makePush(size uint64, pushByteSize int) executionFunc { interpreter.evm.TxContext.Accesses.TouchAddressAndChargeGas(index, nil) // in the case of PUSH32, the end data might be two chunks away, - // so also get the middle chunk. - if pushByteSize == 32 { + // so also get the middle chunk. There is a boundary condition + // check (endMin > 2) in the case the code is a single PUSH32 + // insctruction, whose immediate are just 0s. + if pushByteSize == 32 && endMin > 2 { chunk = uint64(endMin-2) / 31 count = uint64(0) // Look for the first code byte (i.e. no pushdata)