Skip to content

Commit

Permalink
fix(ebpf): try to assert only when it is not nil
Browse files Browse the repository at this point in the history
The normalizeTimeArg function was not checking if the value was nil
before asserting it as an uint64.

This also adds the type to the error message.
  • Loading branch information
geyslan committed Sep 27, 2024
1 parent 1a0065b commit 87b57e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/ebpf/processor_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,13 @@ func (t *Tracee) normalizeTimeArg(argNames ...string) func(event *trace.Event) e
if arg == nil {
return errfmt.Errorf("couldn't find argument %s of event %s", argName, event.EventName)
}
if arg.Value == nil {
continue
}

argTime, ok := arg.Value.(uint64)
if !ok {
return errfmt.Errorf("argument %s of event %s is not of type uint64", argName, event.EventName)
return errfmt.Errorf("argument %s of event %s is not uint64, it is %T", argName, event.EventName, arg.Value)
}
arg.Value = time.BootToEpochNS(argTime)
}
Expand Down

0 comments on commit 87b57e6

Please sign in to comment.