From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id F290A1B2C1; Wed, 9 May 2018 15:37:37 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 06:37:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,381,1520924400"; d="scan'208";a="39899714" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.55]) by orsmga008.jf.intel.com with SMTP; 09 May 2018 06:37:31 -0700 Received: by (sSMTP sendmail emulation); Wed, 09 May 2018 14:37:30 +0100 Date: Wed, 9 May 2018 14:37:29 +0100 From: Bruce Richardson To: Reshma Pattan Cc: dev@dpdk.org, stable@dpdk.org Message-ID: <20180509133729.GB25048@bricha3-MOBL.ger.corp.intel.com> References: <1525865729-16086-1-git-send-email-reshma.pattan@intel.com> <1525865729-16086-3-git-send-email-reshma.pattan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525865729-16086-3-git-send-email-reshma.pattan@intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: replace strncpy with strlcpy 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: Wed, 09 May 2018 13:37:38 -0000 On Wed, May 09, 2018 at 12:35:29PM +0100, Reshma Pattan wrote: > Use strlcpy instead of strncpy. > > Fixes: db75c7af19 ("examples/vhost_scsi: introduce a new sample app") > CC: stable@dpdk.org > > Signed-off-by: Reshma Pattan > --- > examples/vhost_scsi/scsi.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c > index 2a034bb9b..dd5be3c7e 100644 > --- a/examples/vhost_scsi/scsi.c > +++ b/examples/vhost_scsi/scsi.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > #include "vhost_scsi.h" > #include "scsi_spec.h" > @@ -181,7 +182,7 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev, > break; > case SPC_VPD_UNIT_SERIAL_NUMBER: > hlen = 4; > - strncpy((char *)vpage->params, bdev->name, 32); > + strlcpy((char *)vpage->params, bdev->name, 32); > vpage->alloc_len = rte_cpu_to_be_16(32); > break; > case SPC_VPD_DEVICE_IDENTIFICATION: > @@ -215,10 +216,10 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev, > desig->piv = 1; > desig->reserved1 = 0; > desig->len = 8 + 16 + 32; > - strncpy((char *)desig->desig, "INTEL", 8); > + strlcpy((char *)desig->desig, "INTEL", 8); > vhost_strcpy_pad((char *)&desig->desig[8], > bdev->product_name, 16, ' '); > - strncpy((char *)&desig->desig[24], bdev->name, 32); > + strlcpy((char *)&desig->desig[24], bdev->name, 32); > len += sizeof(struct scsi_desig_desc) + 8 + 16 + 32; > > buf += sizeof(struct scsi_desig_desc) + desig->len; > @@ -275,7 +276,7 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev, > inqdata->flags3 = 0x2; > > /* T10 VENDOR IDENTIFICATION */ > - strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8); > + strlcpy((char *)inqdata->t10_vendor_id, "INTEL", 8); > > /* PRODUCT IDENTIFICATION */ > snprintf((char *)inqdata->product_id, > @@ -283,7 +284,7 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev, > bdev->product_name); > > /* PRODUCT REVISION LEVEL */ > - strncpy((char *)inqdata->product_rev, "0001", 4); > + strlcpy((char *)inqdata->product_rev, "0001", 4); > > /* Standard inquiry data ends here. Only populate > * remaining fields if alloc_len indicates enough > -- Can the magic numbers "32", "8", "4" be replaced with non-magic values, e.g. sizeof(...). /Bruce