Skip to content

Commit

Permalink
[options] Add check for MaxUint
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Dec 11, 2024
1 parent 737f2bf commit a38a569
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions options/arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strconv"
"strings"

"github.com/essentialkaos/ek/v13/mathutil"
"github.com/essentialkaos/ek/v13/path"
)

Expand Down Expand Up @@ -195,12 +196,7 @@ func (a Argument) Int64() (int64, error) {
// Uint converts argument to uint
func (a Argument) Uint() (uint, error) {
u, err := strconv.ParseUint(string(a), 10, 64)

if u > math.MaxUint {
return math.MaxUint, fmt.Errorf("Argument value exceeds maximum uint size")
}

return uint(u), err
return uint(mathutil.Min(u, math.MaxUint)), err

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an unsigned 64-bit integer from
strconv.ParseUint
to a lower bit size type uint without an upper bound check.
}

// Uint converts argument to uint64
Expand Down

0 comments on commit a38a569

Please sign in to comment.