net/af_xdp: use strlcpy instead of strncpy
authorCiara Loftus <ciara.loftus@intel.com>
Wed, 7 Oct 2020 09:20:50 +0000 (09:20 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 17:18:47 +0000 (19:18 +0200)
strncpy may leave the destination buffer not NULL terminated so use
strlcpy instead.

Coverity issue: 362975
Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue")
Cc: stable@dpdk.org
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/af_xdp/rte_eth_af_xdp.c

index eaf2c9c..ac00cba 100644 (file)
@@ -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);
+       strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
        ret = ioctl(fd, SIOCETHTOOL, &ifr);
        if (ret) {
                if (errno == EOPNOTSUPP) {