Jelajahi Sumber

fix potential null deref

Sebastien Blot 2 tahun lalu
induk
melakukan
3f56a0759f
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      pkg/acquisition/modules/loki/loki.go

+ 6 - 2
pkg/acquisition/modules/loki/loki.go

@@ -282,6 +282,10 @@ func (l *LokiSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb) er
 		for {
 		for {
 			select {
 			select {
 			case resp := <-respChan:
 			case resp := <-respChan:
+				if resp == nil {
+					ll.Warnf("got nil response from loki tail")
+					continue
+				}
 				if len(resp.DroppedEntries) > 0 {
 				if len(resp.DroppedEntries) > 0 {
 					ll.Warnf("%d entries dropped from loki response", len(resp.DroppedEntries))
 					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 {
 func (l *LokiSource) CanRun() error {
-	return nil // it's ok, even BSD can use Loki
+	return nil
 }
 }
 
 
 func (l *LokiSource) Dump() interface{} {
 func (l *LokiSource) Dump() interface{} {
 	return l
 	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 {
 func (l *LokiSource) SupportedModes() []string {
 	return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
 	return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
 }
 }