[PATCH] app/dumpcap:fix coredump problem because pcap_dump 3th argument is null
Stephen Hemminger
stephen at networkplumber.org
Fri Oct 11 16:30:46 CEST 2024
On Fri, 1 Mar 2024 18:41:29 +0800
Tianli Lai <laitianli at tom.com> wrote:
> if rte_pktmbuf_read() return NULL, pcap_dump() would coredump.
>
> Signed-off-by: Tianli Lai <laitianli at tom.com>
To safely handle jumbo packets, the code here should increase
the size of temp_data, then the RTE_MIN() is not needed either.
See drivers/net/pcap/pcap_ethdev.c
for (i = 0; i < nb_pkts; i++) {
mbuf = bufs[i];
len = caplen = rte_pktmbuf_pkt_len(mbuf);
if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) &&
len > sizeof(temp_data))) {
caplen = sizeof(temp_data);
}
calculate_timestamp(&header.ts);
header.len = len;
header.caplen = caplen;
/* rte_pktmbuf_read() returns a pointer to the data directly
* 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, caplen, temp_data));
More information about the dev
mailing list