dpdk/0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch

33 lines
1.0 KiB
Diff

From 28be6f7f94f85dd15e1807abb6d14a1164b4396d Mon Sep 17 00:00:00 2001
From: jiangheng12 <jiangheng14@huawei.com>
Date: Sat, 17 Jun 2023 20:29:39 +0800
Subject: [PATCH] pdump: fix pcap_dump coredump caused by incorrect pkt_len
---
drivers/net/pcap/rte_eth_pcap.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index aa7ef6f..18b2f30 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -342,8 +342,13 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
* in the mbuf (when the mbuf is contiguous) or, otherwise,
* a pointer to temp_data after copying into it.
*/
- pcap_dump((u_char *)dumper, &header,
- rte_pktmbuf_read(mbuf, 0, len, temp_data));
+ const void *sp = rte_pktmbuf_read(mbuf, 0, len, temp_data);
+ if (sp == NULL) {
+ rte_pktmbuf_free(mbuf);
+ continue;
+ } else {
+ pcap_dump((u_char *)dumper, &header, sp);
+ }
num_tx++;
tx_bytes += len;
--
2.23.0