Skip to content

Commit

Permalink
fix(decl): return error if openMode is negative
Browse files Browse the repository at this point in the history
Fixes lint error G115: integer overflow conversion int -> uint64 (gosec)
  • Loading branch information
jacalvo committed Nov 11, 2024
1 parent 6981eb0 commit 3bf6c96
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/test/step/syscall/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type baseSyscall struct {
// Verify that baseSyscall implements syscall.Syscall interface.
var _ syscall.Syscall = (*baseSyscall)(nil)

var errOpenModeMustBePositive = fmt.Errorf("open mode must be a positive integer")

// New creates a new generic system call test step.
func New(stepName string, rawArgs map[string]string, fieldBindings []*step.FieldBinding, argsContainer,
bindOnlyArgsContainer, retValueContainer reflect.Value, defaultedArgs []string,
Expand Down Expand Up @@ -173,6 +175,9 @@ func setArgFieldValue(argField *field.Field, value string) error {
if err != nil {
return fmt.Errorf("cannot parse value as open mode: %w", err)
}
if openMode < 0 {
return errOpenModeMustBePositive
}
argFieldValue.SetUint(uint64(openMode))
case field.TypeOpenHow:
openHow, err := parseOpenHow(value)
Expand Down

0 comments on commit 3bf6c96

Please sign in to comment.