diff --git a/CHANGELOG.md b/CHANGELOG.md index 13aa27f..3553a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Check for nil packet and transport layer when streaming pcap files [#88](https://github.com/elastic/stream/pull/88) + ### Removed ## [0.14.0] 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)