All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Reshma Pattan <reshma.pattan@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: Re: [PATCH] examples/vhost_scsi: replace strncpy with strlcpy
Date: Wed, 9 May 2018 14:37:29 +0100	[thread overview]
Message-ID: <20180509133729.GB25048@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <1525865729-16086-3-git-send-email-reshma.pattan@intel.com>

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 <reshma.pattan@intel.com>
> ---
>  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 <rte_log.h>
>  #include <rte_malloc.h>
>  #include <rte_byteorder.h>
> +#include <rte_string_fns.h>
>  
>  #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

  reply	other threads:[~2018-05-09 13:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 11:35 [PATCH] examples/ipsec-secgw: replace strncpy with strlcpy Reshma Pattan
2018-05-09 11:35 ` [PATCH] examples/quota_watermark: fix gcc 8.0.1 cast between incompatible types Reshma Pattan
2018-05-11 15:48   ` [dpdk-stable] " De Lara Guarch, Pablo
2018-05-13 21:45   ` Thomas Monjalon
2018-05-09 11:35 ` [PATCH] examples/vhost_scsi: replace strncpy with strlcpy Reshma Pattan
2018-05-09 13:37   ` Bruce Richardson [this message]
2018-05-09 16:38     ` Pattan, Reshma
2018-05-10 12:24     ` Pattan, Reshma
2018-05-10 12:05   ` [PATCH v2] " Reshma Pattan
2018-05-10 13:31     ` Bruce Richardson
2018-05-13 21:50       ` Thomas Monjalon
2018-05-09 13:35 ` [PATCH] examples/ipsec-secgw: " Bruce Richardson
2018-05-09 15:56 ` [PATCH v2] " Reshma Pattan
2018-05-09 16:11   ` [PATCH v3] " Reshma Pattan
2018-05-11 16:38     ` [dpdk-stable] " De Lara Guarch, Pablo
2018-05-13 21:52       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180509133729.GB25048@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.