Skip to content

Commit 6fda80a

Browse files
decanusholiman
authored andcommitted
common/math: fix out of bounds access in json unmarshalling (ethereum#30014)
Co-authored-by: Martin Holst Swende <[email protected]>
1 parent b274a27 commit 6fda80a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

common/math/big.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func NewHexOrDecimal256(x int64) *HexOrDecimal256 {
5353
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
5454
// quoted decimal strings.
5555
func (i *HexOrDecimal256) UnmarshalJSON(input []byte) error {
56-
if len(input) > 0 && input[0] == '"' {
56+
if len(input) > 1 && input[0] == '"' {
5757
input = input[1 : len(input)-1]
5858
}
5959
return i.UnmarshalText(input)

common/math/integer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type HexOrDecimal64 uint64
4646
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
4747
// quoted decimal strings.
4848
func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error {
49-
if len(input) > 0 && input[0] == '"' {
49+
if len(input) > 1 && input[0] == '"' {
5050
input = input[1 : len(input)-1]
5151
}
5252
return i.UnmarshalText(input)

0 commit comments

Comments
 (0)