Skip to content

Commit

Permalink
Update usergroup parsing to always parse as int32
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
dmcgowan committed Dec 19, 2024
1 parent b42c6ad commit 75a8139
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/usergroup/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func parseSubidFile(path, username string) (subIDRanges, error) {
return rangeList, fmt.Errorf("Cannot parse subuid/gid information: Format not correct for %s file", path)
}
if parts[0] == username || username == "ALL" {
startid, err := strconv.Atoi(parts[1])
startid, err := strconv.ParseUint(parts[1], 10, 32)
if err != nil {
return rangeList, fmt.Errorf("String to int conversion failed during subuid/gid parsing of %s: %v", path, err)
}
length, err := strconv.Atoi(parts[2])
length, err := strconv.ParseUint(parts[2], 10, 32)
if err != nil {
return rangeList, fmt.Errorf("String to int conversion failed during subuid/gid parsing of %s: %v", path, err)
}
rangeList = append(rangeList, subIDRange{startid, length})
rangeList = append(rangeList, subIDRange{int(startid), int(length)})

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

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

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

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

Expand Down

0 comments on commit 75a8139

Please sign in to comment.