Skip to content

Commit

Permalink
auditd: Skip trailing zeroes in kernel version (#6109)
Browse files Browse the repository at this point in the history
Remove trailing zeroes from kernel version to avoid polluting
the logs.
  • Loading branch information
adriansr authored and andrewkroh committed Jan 19, 2018
1 parent d2b6359 commit 72de9ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions auditbeat/module/auditd/audit_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func createAuditdData(data map[string]string) common.MapStr {

// stream type

// stream receives callbacks from the libaudit.Reassmbler for completed events
// stream receives callbacks from the libaudit.Reassembler for completed events
// or lost events that are detected by gaps in sequence numbers.
type stream struct {
done <-chan struct{}
Expand Down Expand Up @@ -561,15 +561,17 @@ func kernelVersion() (major, minor int, full string, err error) {
return 0, 0, "", err
}

data := make([]byte, len(uname.Release))
length := len(uname.Release)
data := make([]byte, length)
for i, v := range uname.Release {
if v == 0 {
length = i
break
}
data[i] = byte(v)
}

release := string(data)
release := string(data[:length])
parts := strings.SplitN(release, ".", 3)
if len(parts) < 2 {
return 0, 0, release, errors.Errorf("failed to parse uname release '%v'", release)
Expand Down

0 comments on commit 72de9ed

Please sign in to comment.