From 907d125e2c3a4801558c2f6988e54f427e1b444a Mon Sep 17 00:00:00 2001 From: Sebastian Basierski Date: Tue, 19 Sep 2017 13:41:04 +0200 Subject: [PATCH] net/virtio-user: fix TAP name string termination Fix calling strncpy with the a maximum size equal of destination array size. Coverity issue: 140732 Fixes: e3b434818bbb ("net/virtio-user: support kernel vhost") Cc: stable@dpdk.org Signed-off-by: Sebastian Basierski Acked-by: Jianfeng Tan Acked-by: Yuanhan Liu --- drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c index f585de8c33..689a5cff75 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c @@ -95,9 +95,9 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq) ifr.ifr_flags |= IFF_MULTI_QUEUE; if (*p_ifname) - strncpy(ifr.ifr_name, *p_ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, *p_ifname, IFNAMSIZ - 1); else - strncpy(ifr.ifr_name, "tap%d", IFNAMSIZ); + strncpy(ifr.ifr_name, "tap%d", IFNAMSIZ - 1); if (ioctl(tapfd, TUNSETIFF, (void *)&ifr) == -1) { PMD_DRV_LOG(ERR, "TUNSETIFF failed: %s", strerror(errno)); goto error; -- 2.20.1