From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Cc: huawei.xie@intel.com, John McNamara <john.mcnamara@intel.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>
Subject: [dpdk-dev] [PATCH 2/3] vhost: fix not null terminated string
Date: Tue, 28 Jun 2016 11:58:30 +0800 [thread overview]
Message-ID: <1467086311-13527-3-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1467086311-13527-1-git-send-email-yuanhan.liu@linux.intel.com>
Fix an issue raised by Coverity.
>>> CID 127475: Memory - illegal accesses (BUFFER_SIZE_WARNING)
>>> Calling strncpy with a maximum size argument of 108 bytes on
>>> destination array "un->sun_path" of size 108 bytes might leave
>>> the destination string unterminated.
441 strncpy(un->sun_path, path, sizeof(un->sun_path));
442
443 return fd;
444 }
Coverity issue: 127475
Fixes: 64ab701c3d1e ("vhost: add vhost-user client mode")
Reported-by: John McNamara <john.mcnamara@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
lib/librte_vhost/vhost_user/vhost-net-user.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c
index 90cc127..67303a4 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -439,6 +439,7 @@ create_unix_socket(const char *path, struct sockaddr_un *un, bool is_server)
memset(un, 0, sizeof(*un));
un->sun_family = AF_UNIX;
strncpy(un->sun_path, path, sizeof(un->sun_path));
+ un->sun_path[sizeof(un->sun_path) - 1] = '\0';
return fd;
}
--
1.9.0
next prev parent reply other threads:[~2016-06-28 3:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 3:58 [dpdk-dev] [PATCH 0/3] vhost coverity issue fixes Yuanhan Liu
2016-06-28 3:58 ` [dpdk-dev] [PATCH 1/3] vhost: fix memory leak Yuanhan Liu
2016-06-28 3:58 ` Yuanhan Liu [this message]
2016-06-28 3:58 ` [dpdk-dev] [PATCH 3/3] vhost: fix potential NULL pointer dereference Yuanhan Liu
2016-06-30 15:58 ` [dpdk-dev] [PATCH 0/3] vhost coverity issue fixes Mcnamara, John
2016-07-01 1:56 ` Yuanhan Liu
2016-07-01 2:00 ` Yuanhan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467086311-13527-3-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.com \
--cc=john.mcnamara@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).