All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] app/dumpcap:fix coredump problem because pcap_dump 3th argument is null
@ 2024-03-01 10:41 Tianli Lai
  2024-03-01  3:36 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tianli Lai @ 2024-03-01 10:41 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, Stephen Hemminger

if rte_pktmbuf_read() return NULL, pcap_dump() would coredump.

Signed-off-by: Tianli Lai <laitianli@tom.com>
---
 app/dumpcap/main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index d57db0589a..c941fb92bf 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -878,6 +878,7 @@ pcap_write_packets(pcap_dumper_t *dumper,
 	struct pcap_pkthdr header;
 	uint16_t i;
 	size_t total = 0;
+	const void *data;
 
 	gettimeofday(&header.ts, NULL);
 
@@ -886,9 +887,12 @@ pcap_write_packets(pcap_dumper_t *dumper,
 
 		header.len = rte_pktmbuf_pkt_len(m);
 		header.caplen = RTE_MIN(header.len, sizeof(temp_data));
-
-		pcap_dump((u_char *)dumper, &header,
-			  rte_pktmbuf_read(m, 0, header.caplen, temp_data));
+		data = rte_pktmbuf_read(m, 0, header.caplen, temp_data);
+		if (!data) {
+			rte_pktmbuf_free(m);
+			continue;
+		}
+		pcap_dump((u_char *)dumper, &header, data);
 
 		total += sizeof(header) + header.len;
 	}
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-11 14:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 10:41 [PATCH] app/dumpcap:fix coredump problem because pcap_dump 3th argument is null Tianli Lai
2024-03-01  3:36 ` Stephen Hemminger
2024-10-03 22:09 ` [PATCH] app/dumpcap: fix handling of jumbo frames Stephen Hemminger
2024-10-11 12:46   ` David Marchand
2024-10-11 14:30 ` [PATCH] app/dumpcap:fix coredump problem because pcap_dump 3th argument is null Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.