From c61f309df3cda6ce6bed4ea0b2307036f0393b26 Mon Sep 17 00:00:00 2001 From: Panos Koutsovasilis Date: Mon, 1 Apr 2024 00:38:46 +0300 Subject: [PATCH] fix[pcap]: check for nil packet and transport layer --- internal/command/pcap.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/command/pcap.go b/internal/command/pcap.go index 5bb990b..afe4260 100644 --- a/internal/command/pcap.go +++ b/internal/command/pcap.go @@ -71,7 +71,18 @@ func (r *pcapRunner) sendPCAP(path string, out output.Output) error { break } - payloadData := packet.TransportLayer().LayerPayload() + if packet == nil { + logger.Warnw("Skipping nil packet") + continue + } + + tl := packet.TransportLayer() + if tl == nil { + logger.Warnw("Skipping packet with no transport layer") + continue + } + + payloadData := tl.LayerPayload() // TODO: Rate-limit for UDP. n, err := out.Write(payloadData)