From patchwork Thu Oct 12 11:34:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Piasecki X-Patchwork-Id: 30250 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A6FE91B25D; Thu, 12 Oct 2017 13:36:36 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id ABDCF1B25A; Thu, 12 Oct 2017 13:36:34 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2017 04:36:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,365,1503385200"; d="scan'208"; a="1205038204" Received: from gklab-246-073.igk.intel.com (HELO Sent) ([10.217.246.73]) by fmsmga001.fm.intel.com with SMTP; 12 Oct 2017 04:36:30 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 12 Oct 2017 13:35:04 +0200 From: Jacek Piasecki To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, michalx.k.jastrzebski@intel.com, Jacek Piasecki , changpeng.liu@intel.com, stable@dpdk.org Date: Thu, 12 Oct 2017 13:34:21 +0200 Message-Id: <1507808061-37679-1-git-send-email-jacekx.piasecki@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> References: <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> Subject: [dpdk-dev] [PATCH v3] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Maxime Coquelin --- examples/vhost_scsi/scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c index 54d3104..2de3110 100644 --- a/examples/vhost_scsi/scsi.c +++ b/examples/vhost_scsi/scsi.c @@ -307,7 +307,9 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev, 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);