Skip to content

Commit

Permalink
common/math: fix out of bounds access in json unmarshalling (ethereum…
Browse files Browse the repository at this point in the history
…#30014)


Co-authored-by: Martin Holst Swende <[email protected]>
  • Loading branch information
decanus and holiman committed Jun 17, 2024
1 parent c736b04 commit d866449
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/math/big.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) > 1 && input[0] == '"' {
input = input[1 : len(input)-1]
}
return i.UnmarshalText(input)
Expand Down
2 changes: 1 addition & 1 deletion common/math/integer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d866449

Please sign in to comment.