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 60226A00C3; Fri, 15 May 2020 09:11:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35CB81DA4B; Fri, 15 May 2020 09:11:14 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id A47E01DA45 for ; Fri, 15 May 2020 09:11:12 +0200 (CEST) IronPort-SDR: 5Q52CzA8EK8k/n2lt+DC2pQ/PVCmw7abW+nYArXzPGQkZ/l6Tc4xRd6g2LBwLYAch1rvFDznEd IC1ABywFubuA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2020 00:11:11 -0700 IronPort-SDR: PZyqHj9ZmDwQ99z6ravHTfDnL+CdJdQ8iO6PRCMEQ+x+Tqc5smErXZxHtbQ6HCBzesAmCzNagA vxh3nDwClMPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208";a="438213205" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.116.183]) by orsmga005.jf.intel.com with ESMTP; 15 May 2020 00:11:10 -0700 Date: Fri, 15 May 2020 15:02:54 +0800 From: Ye Xiaolong To: Jin Yu Cc: Maxime Coquelin , Zhihong Wang , dev@dpdk.org Message-ID: <20200515070254.GB1064@intel.com> References: <20200508130254.39929-1-jin.yu@intel.com> <20200515144502.14043-1-jin.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515144502.14043-1-jin.yu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v2] 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" On 05/15, Jin Yu wrote: >In vhost_blk_bdev_construct: The string buffer may not have >a null terminator if the source string's length is equal to >the buffer size. > >Fixes: 91d3e2d42997 ("examples/vhost_blk: refactor to increase readability") >Cc: jin.yu@intel.com > >Signed-off-by: Jin Yu >--- >V2 - update the commit message >--- > 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 95a050855..f4c59437a 100644 >--- a/examples/vhost_blk/vhost_blk.c >+++ b/examples/vhost_blk/vhost_blk.c >@@ -750,8 +750,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 > Reviewed-by: Xiaolong Ye