From dc0fbc26d8c166ef93cda333872d9f51137a6e8f Mon Sep 17 00:00:00 2001 From: lightclient Date: Fri, 26 Sep 2025 07:09:58 -0600 Subject: [PATCH] internal/ethapi: pad string before checking length --- internal/ethapi/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d648feaf96..a591182e5d 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -446,12 +446,12 @@ func decodeHash(s string) (h common.Hash, inputLength int, err error) { if strings.HasPrefix(s, "0x") || strings.HasPrefix(s, "0X") { s = s[2:] } - if len(s) > 64 { // 32 bytes - return common.Hash{}, len(s) / 2, errors.New("hex string too long, want at most 32 bytes") - } if (len(s) & 1) > 0 { s = "0" + s } + if len(s) > 64 { + return common.Hash{}, len(s) / 2, errors.New("hex string too long, want at most 32 bytes") + } b, err := hex.DecodeString(s) if err != nil { return common.Hash{}, 0, errors.New("hex string invalid")