From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 09C6A7CDE; Fri, 22 Sep 2017 15:10:05 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2017 06:10:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,427,1500966000"; d="scan'208";a="1222368673" Received: from unknown ([10.103.102.61]) by fmsmga002.fm.intel.com with SMTP; 22 Sep 2017 06:10:02 -0700 Received: by (sSMTP sendmail emulation); Fri, 22 Sep 2017 15:10:01 +0200 From: Michal Jastrzebski To: yliu@fridaylinux.org, maxime.coquelin@redhat.com Cc: dev@dpdk.org, deepak.k.jain@intel.com, Jacek Piasecki , changpeng.liu@intel.com, stable@dpdk.org Date: Fri, 22 Sep 2017 15:09:59 +0200 Message-Id: <20170922130959.13484-1-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 2.12.2 Subject: [dpdk-stable] [PATCH] examples/vhost_scsi: fix buffer not terminated X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Sep 2017 13:10:06 -0000 From: Jacek Piasecki Fix size of buffer in strcpy. There was possible to get not terminated string after copy operation. Coverity issue: 158629 Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app") Cc: changpeng.liu@intel.com Cc: stable@dpdk.org Signed-off-by: Jacek Piasecki --- examples/vhost_scsi/vhost_scsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c index b4f1f8d..b1a8c93 100644 --- a/examples/vhost_scsi/vhost_scsi.c +++ b/examples/vhost_scsi/vhost_scsi.c @@ -186,8 +186,9 @@ static uint64_t gpa_to_vva(int vid, uint64_t gpa) if (!bdev) return NULL; - strncpy(bdev->name, bdev_name, sizeof(bdev->name)); - strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name)); + strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1); + strncpy(bdev->product_name, bdev_serial, + sizeof(bdev->product_name) - 1); bdev->blocklen = blk_size; bdev->blockcnt = blk_cnt; bdev->write_cache = wce_enable; -- 1.9.1