patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Pattan, Reshma" <reshma.pattan@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: replace strncpy with strlcpy
Date: Wed, 9 May 2018 16:38:01 +0000	[thread overview]
Message-ID: <3AEA2BF9852C6F48A459DA490692831F2A2EDE55@irsmsx110.ger.corp.intel.com> (raw)
In-Reply-To: <20180509133729.GB25048@bricha3-MOBL.ger.corp.intel.com>

Hi Bruce,

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Wednesday, May 9, 2018 2:37 PM
> To: Pattan, Reshma <reshma.pattan@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] examples/vhost_scsi: replace strncpy with
> strlcpy
> 
> 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>
> > ---
> > -			strncpy((char *)vpage->params, bdev->name, 32);
> > +			strlcpy((char *)vpage->params, bdev->name, 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);
> >
> >
> > --
> Can the magic numbers "32", "8", "4" be replaced with non-magic values, e.g.
> sizeof(...).
> 
If I take below piece of code as example ,  the application is trying to copy 
below strings to bare array which has no size defined to it. 
Neither there are any variable  like brand name or device name available in desig object which of type `struct scsi_desig_desc`,  which I can use to pass on to sizeof()  for using it for strlcpy. So not sure how to do address the comment of using sizeof(). Any suggestions?

    strlcpy((char *)desig->desig, "INTEL", 8);
    strlcpy((char *)&desig->desig[24], bdev->name, 32);

/* designation descriptor */
struct scsi_desig_desc {
uint8_t code_set>*******: 4;
uint8_t protocol_id>****: 4;
uint8_t type>***>*******: 4;
uint8_t association>****: 2;
uint8_t reserved0>******: 1;
uint8_t piv>****>*******: 1;
uint8_t reserved1;
uint8_t>len;
uint8_t desig[];
};

Thanks,
Reshma

  reply	other threads:[~2018-05-09 16:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 11:35 [dpdk-stable] [PATCH] examples/ipsec-secgw: " Reshma Pattan
2018-05-09 11:35 ` [dpdk-stable] [PATCH] examples/quota_watermark: fix gcc 8.0.1 cast between incompatible types Reshma Pattan
2018-05-11 15:48   ` De Lara Guarch, Pablo
2018-05-13 21:45   ` Thomas Monjalon
2018-05-09 11:35 ` [dpdk-stable] [PATCH] examples/vhost_scsi: replace strncpy with strlcpy Reshma Pattan
2018-05-09 13:37   ` [dpdk-stable] [dpdk-dev] " Bruce Richardson
2018-05-09 16:38     ` Pattan, Reshma [this message]
2018-05-10 12:24     ` Pattan, Reshma
2018-05-10 12:05   ` [dpdk-stable] [PATCH v2] " Reshma Pattan
2018-05-10 13:31     ` Bruce Richardson
2018-05-13 21:50       ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2018-05-09 13:35 ` [dpdk-stable] [dpdk-dev] [PATCH] examples/ipsec-secgw: " Bruce Richardson
2018-05-09 15:56 ` [dpdk-stable] [PATCH v2] " Reshma Pattan
2018-05-09 16:11   ` [dpdk-stable] [PATCH v3] " Reshma Pattan
2018-05-11 16:38     ` 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=3AEA2BF9852C6F48A459DA490692831F2A2EDE55@irsmsx110.ger.corp.intel.com \
    --to=reshma.pattan@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).