[PATCH 2/3] eventdev: improve bounds checks for names in adapter create
Bruce Richardson
bruce.richardson at intel.com
Tue Jun 23 16:19:28 CEST 2026
The bounds checks for snprintf and then strncpy used different constant
defines, which happened to resolve to the same value (32). Make this
code more resilient by using sizeof() operator rather than the defines,
and replace use of strncpy with the better strlcpy.
Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation")
Cc: stable at dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
lib/eventdev/rte_event_eth_tx_adapter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 91c7be55c7..d531da5d69 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -748,7 +748,7 @@ txa_service_adapter_create_ext(uint8_t id, struct rte_eventdev *dev,
return -EINVAL;
socket_id = dev->data->socket_id;
- snprintf(mem_name, TXA_MEM_NAME_LEN,
+ snprintf(mem_name, sizeof(mem_name),
"rte_event_eth_txa_%d",
id);
@@ -767,7 +767,7 @@ txa_service_adapter_create_ext(uint8_t id, struct rte_eventdev *dev,
txa->id = id;
txa->eventdev_id = dev->data->dev_id;
txa->socket_id = socket_id;
- strncpy(txa->mem_name, mem_name, TXA_SERVICE_NAME_LEN);
+ strlcpy(txa->mem_name, mem_name, sizeof(txa->mem_name));
txa->conf_cb = conf_cb;
txa->conf_arg = conf_arg;
txa->service_id = TXA_INVALID_SERVICE_ID;
--
2.53.0
More information about the dev
mailing list