From 21540df1d83b8ce0afaf759fa949e431212151b9 Mon Sep 17 00:00:00 2001 From: Romeo Rosete Date: Tue, 20 May 2025 10:29:55 -0400 Subject: [PATCH] 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> --- graphql/graphql.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/graphql/graphql.go b/graphql/graphql.go index e23e6fcb0e..2c05e44f5f 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -21,6 +21,7 @@ import ( "context" "errors" "fmt" + "math" "math/big" "sort" "strconv" @@ -58,8 +59,14 @@ func (b *Long) UnmarshalGraphQL(input interface{}) error { if strings.HasPrefix(input, "0x") { // apply leniency and support hex representations of longs. 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) - return err + return nil } else { value, err := strconv.ParseInt(input, 10, 64) *b = Long(value)