Skip to content

Commit

Permalink
fix golint security issue
Browse files Browse the repository at this point in the history
```
pkg/utils/utils.go:211:9: G602: Potentially accessing slice out of bounds (gosec)
	return names[0], nil
```

Signed-off-by: Sebastian Sch <[email protected]>
  • Loading branch information
SchSeba committed Jan 1, 2025
1 parent fca6591 commit 935ebcd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,14 @@ func GetVFLinkName(pciAddr string) (string, error) {
return "", fmt.Errorf("VF device %s sysfs path (%s) has no entries", pciAddr, vfDir)
}

names = make([]string, 0)
for _, f := range fInfos {
names = append(names, f.Name())
names = make([]string, len(fInfos))
for idx, f := range fInfos {
names[idx] = f.Name()
}

if len(names) < 1 {
return "", fmt.Errorf("VF device %s has no entries", pciAddr)
}
return names[0], nil
}

Expand Down

0 comments on commit 935ebcd

Please sign in to comment.