From 734084643447ce481732640715ac8d865bc1f4a5 Mon Sep 17 00:00:00 2001 From: Dean Eigenmann <7621705+decanus@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:40:25 +0200 Subject: [PATCH 1/3] fix potential panic --- common/math/big.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/math/big.go b/common/math/big.go index 721b297c9c4d..2444cca737f9 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -54,7 +54,7 @@ func NewHexOrDecimal256(x int64) *HexOrDecimal256 { // It is similar to UnmarshalText, but allows parsing real decimals too, not just // quoted decimal strings. func (i *HexOrDecimal256) UnmarshalJSON(input []byte) error { - if len(input) > 0 && input[0] == '"' { + if len(input) > 2 && input[0] == '"' { input = input[1 : len(input)-1] } return i.UnmarshalText(input) From 0c9b7dc634779b35b449672c0a50c129da176db4 Mon Sep 17 00:00:00 2001 From: Dean Eigenmann <7621705+decanus@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:42:44 +0200 Subject: [PATCH 2/3] Update big.go --- common/math/big.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/math/big.go b/common/math/big.go index 2444cca737f9..d9748d01a39b 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -54,7 +54,7 @@ func NewHexOrDecimal256(x int64) *HexOrDecimal256 { // It is similar to UnmarshalText, but allows parsing real decimals too, not just // quoted decimal strings. func (i *HexOrDecimal256) UnmarshalJSON(input []byte) error { - if len(input) > 2 && input[0] == '"' { + if len(input) > 1 && input[0] == '"' { input = input[1 : len(input)-1] } return i.UnmarshalText(input) From fe49856ea7100501024dcb907924b0ffc859e71d Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 17 Jun 2024 20:18:23 +0200 Subject: [PATCH 3/3] common/math: fix flaw in HexOrDecimal64 --- common/math/integer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/math/integer.go b/common/math/integer.go index 080fba8fea89..82de96f9272f 100644 --- a/common/math/integer.go +++ b/common/math/integer.go @@ -46,7 +46,7 @@ type HexOrDecimal64 uint64 // It is similar to UnmarshalText, but allows parsing real decimals too, not just // quoted decimal strings. func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error { - if len(input) > 0 && input[0] == '"' { + if len(input) > 1 && input[0] == '"' { input = input[1 : len(input)-1] } return i.UnmarshalText(input)