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 808141B613; Fri, 13 Oct 2017 09:12:38 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45A932D1EC6; Fri, 13 Oct 2017 07:12:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45A932D1EC6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from [10.36.112.24] (ovpn-112-24.ams2.redhat.com [10.36.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6199D60F84; Fri, 13 Oct 2017 07:12:35 +0000 (UTC) To: Jacek Piasecki , dev@dpdk.org Cc: michalx.k.jastrzebski@intel.com, changpeng.liu@intel.com, stable@dpdk.org References: <1507790695-10449-1-git-send-email-jacekx.piasecki@intel.com> <1507808061-37679-1-git-send-email-jacekx.piasecki@intel.com> From: Maxime Coquelin Message-ID: <218441fc-8064-b05f-4eeb-4121dcdf849f@redhat.com> Date: Fri, 13 Oct 2017 09:12:33 +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: <1507808061-37679-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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 13 Oct 2017 07:12:37 +0000 (UTC) Subject: Re: [dpdk-stable] [PATCH v3] 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, 13 Oct 2017 07:12:38 -0000 On 10/12/2017 01:34 PM, 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 > --- > 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); > Acked-by: Maxime Coquelin Thanks, Maxime