From: Jin Yu <jin.yu@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
Zhihong Wang <zhihong.wang@intel.com>,
Xiaolong Ye <xiaolong.ye@intel.com>
Cc: dev@dpdk.org, Jin Yu <jin.yu@intel.com>
Subject: [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated
Date: Fri, 8 May 2020 21:02:54 +0800 [thread overview]
Message-ID: <20200508130254.39929-1-jin.yu@intel.com> (raw)
Fix the potential bug.
Signed-off-by: Jin Yu <jin.yu@intel.com>
---
examples/vhost_blk/vhost_blk.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index f08473f58..b5ce3332a 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -757,8 +757,9 @@ vhost_blk_bdev_construct(const char *bdev_name,
if (!bdev)
return NULL;
- strncpy(bdev->name, bdev_name, sizeof(bdev->name));
- strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
+ snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
+ snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
+ bdev_serial);
bdev->blocklen = blk_size;
bdev->blockcnt = blk_cnt;
bdev->write_cache = wce_enable;
--
2.17.2
next reply other threads:[~2020-05-08 5:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 13:02 Jin Yu [this message]
2020-05-08 8:43 ` [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated Ye Xiaolong
2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
2020-05-15 7:02 ` Ye Xiaolong
2020-05-15 8:39 ` Maxime Coquelin
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=20200508130254.39929-1-jin.yu@intel.com \
--to=jin.yu@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=xiaolong.ye@intel.com \
--cc=zhihong.wang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.