From 30c695c5e2688c7b6ba1b2c58a5bfcb666a7742b Mon Sep 17 00:00:00 2001 From: jwasinger Date: Sun, 24 Apr 2022 21:16:49 -1000 Subject: [PATCH] cmd/evm: ensure input length is even (#24721) * cmd/evm: ensure input length is even * cmd/evm: minor nit + lintfix Co-authored-by: Martin Holst Swende --- cmd/evm/runner.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 6f2d97320d..d57602f8d5 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -246,7 +246,12 @@ func runCmd(ctx *cli.Context) error { } else { hexInput = []byte(ctx.GlobalString(InputFlag.Name)) } - input := common.FromHex(string(bytes.TrimSpace(hexInput))) + hexInput = bytes.TrimSpace(hexInput) + if len(hexInput)%2 != 0 { + fmt.Println("input length must be even") + os.Exit(1) + } + input := common.FromHex(string(hexInput)) var execFunc func() ([]byte, uint64, error) if ctx.GlobalBool(CreateFlag.Name) {