DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: fix buffer not null terminated
@ 2016-05-10 16:11 Daniel Mrzyglod
  2016-05-10 18:27 ` Yuanhan Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Mrzyglod @ 2016-05-10 16:11 UTC (permalink / raw)
  To: huawei.xie, yuanhan.liu, przemyslaw.czesnowicz; +Cc: dev, Daniel Mrzyglod

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 <danielx.t.mrzyglod@intel.com>
---
 lib/librte_vhost/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index d870ad9..f4695af 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';
 }
 
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix buffer not null terminated
  2016-05-10 16:11 [dpdk-dev] [PATCH] vhost: fix buffer not null terminated Daniel Mrzyglod
@ 2016-05-10 18:27 ` Yuanhan Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Yuanhan Liu @ 2016-05-10 18:27 UTC (permalink / raw)
  To: Daniel Mrzyglod; +Cc: huawei.xie, przemyslaw.czesnowicz, dev

On Tue, May 10, 2016 at 06:11:18PM +0200, Daniel Mrzyglod wrote:
> 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 <danielx.t.mrzyglod@intel.com>

Applied to dpdk-next-virtio.

Thanks.

	--yliu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-10 18:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 16:11 [dpdk-dev] [PATCH] vhost: fix buffer not null terminated Daniel Mrzyglod
2016-05-10 18:27 ` Yuanhan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).