mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Potential fix for code scanning alert no. 8: Incorrect conversion between integer types
Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
58818e1660
commit
21540df1d8
1 changed files with 8 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -58,8 +59,14 @@ func (b *Long) UnmarshalGraphQL(input interface{}) error {
|
||||||
if strings.HasPrefix(input, "0x") {
|
if strings.HasPrefix(input, "0x") {
|
||||||
// apply leniency and support hex representations of longs.
|
// apply leniency and support hex representations of longs.
|
||||||
value, err := hexutil.DecodeUint64(input)
|
value, err := hexutil.DecodeUint64(input)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if value > math.MaxInt64 {
|
||||||
|
return fmt.Errorf("value %d exceeds int64 range", value)
|
||||||
|
}
|
||||||
*b = Long(value)
|
*b = Long(value)
|
||||||
return err
|
return nil
|
||||||
} else {
|
} else {
|
||||||
value, err := strconv.ParseInt(input, 10, 64)
|
value, err := strconv.ParseInt(input, 10, 64)
|
||||||
*b = Long(value)
|
*b = Long(value)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue