From 64f27433a172af6d510046b83cf8529bbda69d63 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Thu, 27 Jul 2023 15:53:14 +0530 Subject: [PATCH] af-packet: Error on invalid peer device setting If the copy-iface was set to the same as the af-packet interface, the peer won't be set. This leads to segfault. Catch it and return properly. Bug 5870 --- src/source-af-packet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 0c50ed219aa6..28a3730b469c 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -661,6 +661,10 @@ static void AFPWritePacket(Packet *p, int version) } /* Index of the network device */ + if (p->afp_v.peer == NULL) { + SCLogError("Peer network device invalid"); + return; + } socket_address.sll_ifindex = SC_ATOMIC_GET(p->afp_v.peer->if_idx); /* Address length*/ socket_address.sll_halen = ETH_ALEN;