From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 962161B21E; Thu, 12 Oct 2017 13:09:06 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAD742576A; Thu, 12 Oct 2017 11:09:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AAD742576A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from [10.36.112.53] (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 856AE5C1A3; Thu, 12 Oct 2017 11:09:03 +0000 (UTC) To: Jacek Piasecki , dev@dpdk.org Cc: changpeng.liu@intel.com, deepak.k.jain@intel.com, michalx.k.jastrzebski@intel.com, stable@dpdk.org References: <20170922130734.7256-1-michalx.k.jastrzebski@intel.com> <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> From: Maxime Coquelin Message-ID: <3e38ad76-40c5-078c-8784-7ea08714c625@redhat.com> Date: Thu, 12 Oct 2017 13:09:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 12 Oct 2017 11:09:05 +0000 (UTC) Subject: Re: [dpdk-stable] [PATCH v2] 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: Thu, 12 Oct 2017 11:09:06 -0000 On 10/12/2017 08:44 AM, Jacek Piasecki wrote: > 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); > Acked-by: Maxime Coquelin