From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 27C2843B68; Fri, 1 Mar 2024 03:41:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC904402CD; Fri, 1 Mar 2024 03:41:47 +0100 (CET) Received: from smtp.tom.com (smtprz22.163.net [106.38.219.107]) by mails.dpdk.org (Postfix) with ESMTP id BCECA4025C for ; Fri, 1 Mar 2024 03:41:45 +0100 (CET) Received: from my-app01.tom.com (my-app01.tom.com [127.0.0.1]) by freemail01.tom.com (Postfix) with ESMTP id BF0DA1EA00CF for ; Fri, 1 Mar 2024 10:41:42 +0800 (CST) Received: from my-app01.tom.com (HELO smtp.tom.com) ([127.0.0.1]) by my-app01 (TOM SMTP Server) with SMTP ID -1363278598 for ; Fri, 01 Mar 2024 10:41:42 +0800 (CST) Received: from antispam3.tom.com (unknown [172.25.16.54]) by freemail01.tom.com (Postfix) with ESMTP id B0F1F1EA0091 for ; Fri, 1 Mar 2024 10:41:42 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=201807; t=1709260902; bh=C+4DQhsW1AHE+G5oixVUDK5XC7V2J1P4PPnFmoVO7c8=; h=From:To:Cc:Subject:Date:From; b=AtDamu7BkE4u9vBShsadf+C3pKyGnurTiC8EiAn90bntgtldhF8lEInt5sTgyV7T6 Bt2WxdAu/jQJzvlTWt0o8UtNHq0wSABxI/Wq2QESey/qYftoBDXZHow20i12414zbo 0/n3ksdLFMr5vrL8/SV2joUxuN1P/RaWrcwduQJU= Received: from antispam3.tom.com (antispam3.tom.com [127.0.0.1]) by antispam3.tom.com (Postfix) with ESMTP id 87CC39C1AED for ; Fri, 1 Mar 2024 10:41:42 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at antispam3.tom.com Received: from antispam3.tom.com ([127.0.0.1]) by antispam3.tom.com (antispam3.tom.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GRL7Jr2xYNqj for ; Fri, 1 Mar 2024 10:41:41 +0800 (CST) Received: from localhost.localdomain (unknown [61.141.254.104]) by antispam3.tom.com (Postfix) with ESMTPA id 942649C19F9; Fri, 1 Mar 2024 10:41:41 +0800 (CST) From: Tianli Lai To: dev@dpdk.org Cc: Reshma Pattan , Stephen Hemminger Subject: [PATCH] app/dumpcap:fix coredump problem because pcap_dump 3th argument is null Date: Fri, 1 Mar 2024 18:41:29 +0800 Message-Id: <20240301104129.3725-1-laitianli@tom.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org if rte_pktmbuf_read() return NULL, pcap_dump() would coredump. Signed-off-by: Tianli Lai --- 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