common/math: fix out of bounds access in json unmarshalling (#30014)

Co-authored-by: Martin Holst Swende <martin@swende.se>
pull/30017/head
Dean Eigenmann 5 months ago committed by GitHub
parent c736b04d9b
commit d8664490da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      common/math/big.go
  2. 2
      common/math/integer.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) > 1 && input[0] == '"' {
input = input[1 : len(input)-1]
}
return i.UnmarshalText(input)

@ -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)

Loading…
Cancel
Save