[PATCH 08/17] net/cnxk: replace strncpy with strlcpy
Bruce Richardson
bruce.richardson at intel.com
Tue Jun 23 18:51:38 CEST 2026
Replace strncpy() with safer strlcpy() which always null-terminates.
Fixes: 804c585658ea ("net/cnxk: add representor control plane")
Cc: stable at dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
drivers/net/cnxk/cnxk_eswitch.c | 4 ++--
drivers/net/cnxk/cnxk_rep_msg.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_eswitch.c b/drivers/net/cnxk/cnxk_eswitch.c
index e45c7dfd07..50c3e54109 100644
--- a/drivers/net/cnxk/cnxk_eswitch.c
+++ b/drivers/net/cnxk/cnxk_eswitch.c
@@ -124,8 +124,8 @@ cnxk_eswitch_dev_remove(struct rte_pci_device *pci_dev)
}
sun.sun_family = AF_UNIX;
sunlen = sizeof(struct sockaddr_un);
- strncpy(sun.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH,
- sizeof(sun.sun_path) - 1);
+ strlcpy(sun.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH,
+ sizeof(sun.sun_path));
if (connect(sock_fd, (struct sockaddr *)&sun, sunlen) < 0) {
plt_err("Failed to connect socket: %s, err %d",
diff --git a/drivers/net/cnxk/cnxk_rep_msg.c b/drivers/net/cnxk/cnxk_rep_msg.c
index a222e2b5cd..7b92e7a5f7 100644
--- a/drivers/net/cnxk/cnxk_rep_msg.c
+++ b/drivers/net/cnxk/cnxk_rep_msg.c
@@ -138,7 +138,7 @@ open_socket_ctrl_channel(void)
memset(&un, 0, sizeof(struct sockaddr_un));
un.sun_family = AF_UNIX;
- strncpy(un.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH, sizeof(un.sun_path) - 1);
+ strlcpy(un.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH, sizeof(un.sun_path));
if (bind(sock_fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
plt_err("Failed to bind %s: %s", un.sun_path, strerror(errno));
--
2.53.0
More information about the dev
mailing list