[dpdk-dev] [PATCH] net/af_xdp: use snprintf instead of strncpy
Ferruh Yigit
ferruh.yigit at intel.com
Wed Oct 7 11:40:32 CEST 2020
On 10/7/2020 10:01 AM, Ciara Loftus wrote:
> strncpy may leave the destination buffer not NULL terminated so use
> snprintf instead.
What do you think using 'strlcpy'?
>
> Coverity issue: 362975
> Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue")
> Signed-off-by: Ciara Loftus <ciara.loftus at intel.com>
> ---
> drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index eaf2c9c873..52495cb8fb 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);
> + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name);
> ret = ioctl(fd, SIOCETHTOOL, &ifr);
> if (ret) {
> if (errno == EOPNOTSUPP) {
>
More information about the dev
mailing list