From 3f56a0759f4d179fe2b4f34405da01db66b9d888 Mon Sep 17 00:00:00 2001 From: Sebastien Blot Date: Mon, 28 Nov 2022 13:53:22 +0100 Subject: [PATCH] fix potential null deref --- pkg/acquisition/modules/loki/loki.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/acquisition/modules/loki/loki.go b/pkg/acquisition/modules/loki/loki.go index 60ae2d350..04ffdd367 100644 --- a/pkg/acquisition/modules/loki/loki.go +++ b/pkg/acquisition/modules/loki/loki.go @@ -282,6 +282,10 @@ func (l *LokiSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb) er for { select { case resp := <-respChan: + if resp == nil { + ll.Warnf("got nil response from loki tail") + continue + } if len(resp.DroppedEntries) > 0 { ll.Warnf("%d entries dropped from loki response", len(resp.DroppedEntries)) } @@ -299,14 +303,14 @@ func (l *LokiSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb) er } func (l *LokiSource) CanRun() error { - return nil // it's ok, even BSD can use Loki + return nil } func (l *LokiSource) Dump() interface{} { return l } -//SupportedModes returns the supported modes by the acquisition module +// SupportedModes returns the supported modes by the acquisition module func (l *LokiSource) SupportedModes() []string { return []string{configuration.TAIL_MODE, configuration.CAT_MODE} }