From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id D08F023A; Thu, 12 Oct 2017 08:44:44 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 11 Oct 2017 23:44:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,364,1503385200"; d="scan'208";a="1181165071" Received: from gklab-246-073.igk.intel.com (HELO Sent) ([10.217.246.73]) by orsmga001.jf.intel.com with SMTP; 11 Oct 2017 23:44:40 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 12 Oct 2017 08:45:24 +0200 From: Jacek Piasecki To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, changpeng.liu@intel.com, deepak.k.jain@intel.com, michalx.k.jastrzebski@intel.com, Jacek Piasecki , stable@dpdk.org Date: Thu, 12 Oct 2017 08:44:55 +0200 Message-Id: <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170922130734.7256-1-michalx.k.jastrzebski@intel.com> References: <20170922130734.7256-1-michalx.k.jastrzebski@intel.com> Subject: [dpdk-dev] [PATCH v2] examples/vhost_scsi: fix buffer not 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: , X-List-Received-Date: Thu, 12 Oct 2017 06:44:45 -0000 Use snprintf instead strncpy to get safe null string termination. There was possible to get not terminated string after strncpy operation. Coverity issue: 158631 Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app") Cc: changpeng.liu@intel.com Cc: stable@dpdk.org Signed-off-by: Jacek Piasecki --- v2: * use snprintf instead strncpy examples/vhost_scsi/scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c index 54d3104..c0f3187 100644 --- a/examples/vhost_scsi/scsi.c +++ b/examples/vhost_scsi/scsi.c @@ -307,7 +307,8 @@ strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8); /* PRODUCT IDENTIFICATION */ - strncpy((char *)inqdata->product_id, bdev->product_name, 16); + snprintf((char *)inqdata->product_id, + ARRAY_SIZE(inqdata->product_id), "%s", bdev->product_name); /* PRODUCT REVISION LEVEL */ strncpy((char *)inqdata->product_rev, "0001", 4); -- 1.9.1