DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: yuanhan.liu@linux.intel.com, huawei.xie@intel.com,
	john.mcnamara@intel.com, Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH 2/4] net/virtio-user: fix string overflow
Date: Wed, 29 Jun 2016 09:05:34 +0000	[thread overview]
Message-ID: <1467191137-65087-3-git-send-email-jianfeng.tan@intel.com> (raw)
In-Reply-To: <1467191137-65087-1-git-send-email-jianfeng.tan@intel.com>

When parsing /proc/self/maps to get hugepage information, the string
was being copied with strcpy(), which could, theoretically but in fact
not possiblly, overflow the destination buffer. Anyway, to avoid the
false alarm, we replaced strncpy with snprintf for safely copying the
strings.

Coverity issue: 127484

Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_user/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a159ece..082e821 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -181,7 +181,7 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max)
 		}
 		huges[idx].addr = v_start;
 		huges[idx].size = v_end - v_start;
-		strcpy(huges[idx].path, tmp);
+		snprintf(huges[idx].path, PATH_MAX, "%s", tmp);
 		idx++;
 	}
 
-- 
2.1.4

  parent reply	other threads:[~2016-06-29  9:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29  9:05 [dpdk-dev] [PATCH 0/4] net/virtio-user: fix coverity issues Jianfeng Tan
2016-06-29  9:05 ` [dpdk-dev] [PATCH 1/4] net/virtio-user: fix return value not checked Jianfeng Tan
2016-07-01  2:15   ` Yuanhan Liu
2016-07-05 10:14     ` Tan, Jianfeng
2016-07-05 11:31       ` Yuanhan Liu
2016-06-29  9:05 ` Jianfeng Tan [this message]
2016-06-29  9:05 ` [dpdk-dev] [PATCH 3/4] net/virtio-user: fix resource leaks Jianfeng Tan
2016-06-29  9:05 ` [dpdk-dev] [PATCH 4/4] net/virtio-user: fix string unterminated Jianfeng Tan

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=1467191137-65087-3-git-send-email-jianfeng.tan@intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=john.mcnamara@intel.com \
    --cc=yuanhan.liu@linux.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).