common/hexutil: reject big integer inputs > 256 bits
This follows the change to common/math big integer parsing in PR #3699.
This commit is contained in:
@ -91,9 +91,12 @@ func UnmarshalJSON(typname string, input, out []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Big marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as
|
||||
// "0x0". Negative integers are not supported at this time. Attempting to marshal them
|
||||
// will return an error.
|
||||
// Big marshals/unmarshals as a JSON string with 0x prefix.
|
||||
// The zero value marshals as "0x0".
|
||||
//
|
||||
// Negative integers are not supported at this time. Attempting to marshal them will
|
||||
// return an error. Values larger than 256bits are rejected by Unmarshal but will be
|
||||
// marshaled without error.
|
||||
type Big big.Int
|
||||
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
@ -119,6 +122,9 @@ func (b *Big) UnmarshalJSON(input []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(raw) > 64 {
|
||||
return ErrBig256Range
|
||||
}
|
||||
words := make([]big.Word, len(raw)/bigWordNibbles+1)
|
||||
end := len(raw)
|
||||
for i := range words {
|
||||
|
Reference in New Issue
Block a user