From: Daniel Mrzyglod Date: Tue, 10 May 2016 16:11:18 +0000 (+0200) Subject: vhost: fix name not null terminated X-Git-Tag: spdx-start~6927 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a5e20775a7588042c64f3919787b689f1c861369;p=dpdk.git vhost: fix name not null terminated Fix issue reported by Coverity. Coverity ID 124556 If the buffer is treated as a null terminated string in later operations, a buffer overflow or over-read may occur. In vhost_set_ifname: The string buffer may not have a null terminator if the source string's length is equal to the buffer size Fixes: 54292e9520e0 ("vhost: support ifname for vhost-user") Signed-off-by: Daniel Mrzyglod Acked-by: Yuanhan Liu --- diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index d870ad97ab..f4695afd48 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -320,6 +320,7 @@ vhost_set_ifname(struct vhost_device_ctx ctx, sizeof(dev->ifname) : if_len; strncpy(dev->ifname, if_name, len); + dev->ifname[sizeof(dev->ifname) - 1] = '\0'; }