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 79AD048C54; Sun, 7 Dec 2025 20:13:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71B584064A; Sun, 7 Dec 2025 20:12:57 +0100 (CET) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mails.dpdk.org (Postfix) with ESMTP id 719FE4042F for ; Sun, 7 Dec 2025 20:12:56 +0100 (CET) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so29918595e9.3 for ; Sun, 07 Dec 2025 11:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1765134776; x=1765739576; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3vmW0EapljQF36KN4JI48XscDOxvks/pvjTAp8iLdZ8=; b=rtNQUesgcu/WmzV6D7xL8LPpEnkOVKYWxhQnqZH82dt1Z3gBMAQovkOErxxBOxJMxU Gx8zE0RT8psuA3+WFPsz8mFa3Fj2JL+c72dtTYvzJ2v+T6f3Mx078psOpL7PFAeUtJMi iYyTkIZcHrpezQIR/FaHCYCYWhxZchH9TXGuvRwhMXJdJe09ydjltOTjl/33i9vwfaCS yCzG7H5BPeG1YgvmyuxOPwnxc2l4D2lkcHNO1qs9+zYhaCxfhdFUNyMcCvEsZbdZ+8s3 AD3coOykppRco1ebiff5OFK6xJadSoQfFvD6HKJkiJ3nYpBI05+h4VwUEeRuIM2Cq6OC ThOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765134776; x=1765739576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject: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mc0tmDGP4aQXHweaaoJW8lqL5Mfg== X-Google-Smtp-Source: AGHT+IEqpzGZzYaThhikl328dnQl572fqzdkqwZcY3gdwS7W0rn25aoahAjgbIxFONb7G36QmDvRHw== X-Received: by 2002:a05:600c:8b55:b0:477:a0dd:b2af with SMTP id 5b1f17b1804b1-47939e3e51amr56518345e9.33.1765134776063; Sun, 07 Dec 2025 11:12:56 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479310b8e70sm205124205e9.5.2025.12.07.11.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 11:12:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan Subject: [PATCH v5 04/17] graph: avoid overflowing comment buffer Date: Sun, 7 Dec 2025 11:11:55 -0800 Message-ID: <20251207191242.165619-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251207191242.165619-1-stephen@networkplumber.org> References: <20251205022948.327743-1-stephen@networkplumber.org> <20251207191242.165619-1-stephen@networkplumber.org> 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 The library builds a pcapng comment to put on each packet but the buffer is not big enough for the largest possible graph node name, etc. Change to use asprintf() to allow any string length. Note, if asprintf() fails it is better to still log the packet without comment so no data is lost. Signed-off-by: Stephen Hemminger --- lib/graph/graph_pcap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c index 08dcda0d28..602be79ced 100644 --- a/lib/graph/graph_pcap.c +++ b/lib/graph/graph_pcap.c @@ -194,7 +194,7 @@ graph_pcap_dispatch(struct rte_graph *graph, uint16_t nb_objs) { struct rte_mbuf *mbuf_clones[RTE_GRAPH_BURST_SIZE]; - char buffer[GRAPH_PCAP_BUF_SZ]; + char *comment = NULL; uint64_t i, num_packets; struct rte_mbuf *mbuf; ssize_t len; @@ -207,19 +207,22 @@ graph_pcap_dispatch(struct rte_graph *graph, if (num_packets > nb_objs) num_packets = nb_objs; - snprintf(buffer, GRAPH_PCAP_BUF_SZ, "%s: %s", graph->name, node->name); + /* put a comment on all these packets */ + if (asprintf(&comment, "%s: %s", graph->name, node->name) < 0) + graph_err("asprintf for comment failed."); for (i = 0; i < num_packets; i++) { struct rte_mbuf *mc; mbuf = (struct rte_mbuf *)objs[i]; mc = rte_pcapng_copy(mbuf->port, 0, mbuf, pkt_mp, mbuf->pkt_len, - 0, buffer); + 0, comment); if (mc == NULL) break; mbuf_clones[i] = mc; } + free(comment); /* write it to capture file */ len = rte_pcapng_write_packets(pcapng_fd, mbuf_clones, i); -- 2.51.0