[PATCH v1 08/24] net/ntnic: fix potential format overflow

Serhii Iliushyk sil-plv at napatech.com
Wed Sep 24 16:41:31 CEST 2025


Use snprintf instead sprintf to avoid format overflow

Fixes: d3dc362770d9 ("net/ntnic: add adapter initialization")

Signed-off-by: Serhii Iliushyk <sil-plv at napatech.com>
---
 drivers/net/ntnic/ntnic_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index a867e7b16d..58be82b2d2 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -2613,7 +2613,7 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 	NT_LOG_DBGX(DBG, NTNIC, "PCI device deinitialization");
 
 	int i;
-	char name[32];
+	char name[RTE_ETH_NAME_MAX_LEN];
 
 	struct pmd_internals *internals = eth_dev->data->dev_private;
 	ntdrv_4ga_t *p_ntdrv = &internals->p_drv->ntdrv;
@@ -2640,7 +2640,7 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 	}
 
 	for (i = 0; i < n_phy_ports; i++) {
-		sprintf(name, "ntnic%d", i);
+		snprintf(name, sizeof(name), "ntnic%d", i);
 		eth_dev = rte_eth_dev_allocated(name);
 		if (eth_dev == NULL)
 			continue; /* port already released */
-- 
2.45.0



More information about the dev mailing list