diff mbox series

[v4] net/af_xdp: use rte_strscpy instead of strncpy

Message ID 20201007093854.30573-1-ciara.loftus@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Ferruh Yigit
Headers show
Series [v4] net/af_xdp: use rte_strscpy instead of strncpy | expand


Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Ciara Loftus Oct. 7, 2020, 9:38 a.m. UTC
strncpy may leave the destination buffer not NULL terminated so use
rte_strscpy instead.

Coverity issue: 362975
Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue")
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
* actually use rte_strscpy instead of strlcpy

* use rte_strscpy instead of strlcpy

* use strlcpy instead of snprintf

 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index eaf2c9c873..f394c57a74 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1362,7 +1362,7 @@  xdp_get_channels_info(const char *if_name, int *max_queues,
 	channels.cmd = ETHTOOL_GCHANNELS;
 	ifr.ifr_data = (void *)&channels;
-	strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
+	rte_strscpy(ifr.ifr_name, if_name, IFNAMSIZ);
 	ret = ioctl(fd, SIOCETHTOOL, &ifr);
 	if (ret) {
 		if (errno == EOPNOTSUPP) {