From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C808A00C5; Fri, 8 May 2020 07:24:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 127CD1DC19; Fri, 8 May 2020 07:24:07 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 95EC21DBE7 for ; Fri, 8 May 2020 07:24:05 +0200 (CEST) IronPort-SDR: 0DNajwPO2EbFZYFQhk8PHf0/zvMlHtMXPxTRrxORJTwaI4VHcjeGQG09LuEIGxb/qZXcsRyZ9d 7QdUVyEClE9Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 22:24:04 -0700 IronPort-SDR: 99+UJ1YL7y022s2QcqyDNuNyFO1yM36tP7GYUuPle4ir/rHq3WmYzLhZZCpMjrxitVa+nPxwUt xL7VHvAiYTAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="407903247" Received: from storage36.sh.intel.com ([10.67.111.10]) by orsmga004.jf.intel.com with ESMTP; 07 May 2020 22:24:02 -0700 From: Jin Yu To: Maxime Coquelin , Zhihong Wang , Xiaolong Ye Cc: dev@dpdk.org, Jin Yu Date: Fri, 8 May 2020 21:02:54 +0800 Message-Id: <20200508130254.39929-1-jin.yu@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix the potential bug. Signed-off-by: Jin Yu --- 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