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 E64B41B256; Mon, 2 Oct 2017 17:07:26 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AE9681E15; Mon, 2 Oct 2017 15:07:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5AE9681E15 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from [10.36.112.31] (ovpn-112-31.ams2.redhat.com [10.36.112.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9283A6F989; Mon, 2 Oct 2017 15:07:23 +0000 (UTC) To: "Jastrzebski, MichalX K" , "yliu@fridaylinux.org" Cc: "dev@dpdk.org" , "Jain, Deepak K" , "Piasecki, JacekX" , "Liu, Changpeng" , "stable@dpdk.org" References: <20170922130734.7256-1-michalx.k.jastrzebski@intel.com> <60ABE07DBB3A454EB7FAD707B4BB158213C40F16@IRSMSX109.ger.corp.intel.com> From: Maxime Coquelin Message-ID: <0a469856-29c8-a79e-bb6a-ad21dfbccaf4@redhat.com> Date: Mon, 2 Oct 2017 17:07:22 +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: <60ABE07DBB3A454EB7FAD707B4BB158213C40F16@IRSMSX109.ger.corp.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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 02 Oct 2017 15:07:25 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH] 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: Mon, 02 Oct 2017 15:07:27 -0000 On 10/02/2017 03:50 PM, Jastrzebski, MichalX K wrote: >> -----Original Message----- >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski >> Sent: Friday, September 22, 2017 3:08 PM >> To: yliu@fridaylinux.org; maxime.coquelin@redhat.com >> Cc: dev@dpdk.org; Jain, Deepak K ; Piasecki, >> JacekX ; Liu, Changpeng >> ; stable@dpdk.org >> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated >> >> From: Jacek Piasecki >> >> Fix size of buffer in strcpy. There was possible to get >> not terminated string after copy 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 >> --- >> 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..de9639a 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); >> + strncpy((char *)inqdata->product_id, bdev->product_name, >> + ARRAY_SIZE(inqdata->product_id) - 1); Does it assume that product_id is memzero'ed before? IIUC strncpy manpage, it wouldn't protect against non-null terminated strings if it is not the case: " A simple implementation of strncpy() might be: char * strncpy(char *dest, const char *src, size_t n) { size_t i; for (i = 0; i < n && src[i] != '\0'; i++) dest[i] = src[i]; for ( ; i < n; i++) dest[i] = '\0'; return dest; } " Cheers, Maxime >> >> /* PRODUCT REVISION LEVEL */ >> strncpy((char *)inqdata->product_rev, "0001", 4); >> -- >> 1.9.1 > > Hi Yu / Maxime, > I would like to ask for a feedback regarding proposed fix. > If everything is ok with it, please send acked-by. > > Best regards > Michal. >