All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: jeffrey.t.kirsher@intel.com, intel-wired-lan@lists.osuosl.org,
	netdev <netdev@vger.kernel.org>
Cc: "Mitch Williams" <mitch.a.williams@intel.com>,
	"Patryk Małek" <patryk.malek@intel.com>
Subject: Re: i40e_pto.c: Odd use of strlcpy converted from strncpy
Date: Mon, 07 Oct 2019 13:48:00 -0700	[thread overview]
Message-ID: <02fe65d8989ef1d030cf31c7134c574a242afc17.camel@perches.com> (raw)
In-Reply-To: <a00c9af7d24ac0dd6af8698c9e545591392720fe.camel@intel.com>

On Mon, 2019-10-07 at 13:44 -0700, Jeff Kirsher wrote:
> On Sun, 2019-10-06 at 10:19 -0700, Joe Perches wrote:
> > This got converted from strncpy to strlcpy but it's
> > now not necessary to use one character less than the
> > actual size.
> > 
> > Perhaps the sizeof() - 1 is now not correct and it
> > should use strscpy and a normal sizeof.
[]
> You are also missing you signed-off-by: and Fixes:, I can get your
> change under test in the meantime to confirm your fix.

I didn't sign off as all I intended was to bring it
to your attention.  The diff is just the simplest way.
It's trivial if it's a defect.

> > ---
> >  drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > index 9bf1ad4319f5..627b1c02bb4b 100644
> > --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > @@ -700,8 +700,8 @@ static long i40e_ptp_create_clock(struct i40e_pf
> > *pf)
> >  	if (!IS_ERR_OR_NULL(pf->ptp_clock))
> >  		return 0;
> >  
> > -	strlcpy(pf->ptp_caps.name, i40e_driver_name,
> > -		sizeof(pf->ptp_caps.name) - 1);
> > +	strscpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf-
> > > ptp_caps.name));
> > +
> >  	pf->ptp_caps.owner = THIS_MODULE;
> >  	pf->ptp_caps.max_adj = 999999999;
> >  	pf->ptp_caps.n_ext_ts = 0;
> > 
> > 


WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] i40e_pto.c: Odd use of strlcpy converted from strncpy
Date: Mon, 07 Oct 2019 13:48:00 -0700	[thread overview]
Message-ID: <02fe65d8989ef1d030cf31c7134c574a242afc17.camel@perches.com> (raw)
In-Reply-To: <a00c9af7d24ac0dd6af8698c9e545591392720fe.camel@intel.com>

On Mon, 2019-10-07 at 13:44 -0700, Jeff Kirsher wrote:
> On Sun, 2019-10-06 at 10:19 -0700, Joe Perches wrote:
> > This got converted from strncpy to strlcpy but it's
> > now not necessary to use one character less than the
> > actual size.
> > 
> > Perhaps the sizeof() - 1 is now not correct and it
> > should use strscpy and a normal sizeof.
[]
> You are also missing you signed-off-by: and Fixes:, I can get your
> change under test in the meantime to confirm your fix.

I didn't sign off as all I intended was to bring it
to your attention.  The diff is just the simplest way.
It's trivial if it's a defect.

> > ---
> >  drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > index 9bf1ad4319f5..627b1c02bb4b 100644
> > --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > @@ -700,8 +700,8 @@ static long i40e_ptp_create_clock(struct i40e_pf
> > *pf)
> >  	if (!IS_ERR_OR_NULL(pf->ptp_clock))
> >  		return 0;
> >  
> > -	strlcpy(pf->ptp_caps.name, i40e_driver_name,
> > -		sizeof(pf->ptp_caps.name) - 1);
> > +	strscpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf-
> > > ptp_caps.name));
> > +
> >  	pf->ptp_caps.owner = THIS_MODULE;
> >  	pf->ptp_caps.max_adj = 999999999;
> >  	pf->ptp_caps.n_ext_ts = 0;
> > 
> > 


  reply	other threads:[~2019-10-07 20:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-06 17:19 i40e_pto.c: Odd use of strlcpy converted from strncpy Joe Perches
2019-10-06 17:19 ` [Intel-wired-lan] " Joe Perches
2019-10-07 20:44 ` Jeff Kirsher
2019-10-07 20:44   ` [Intel-wired-lan] " Jeff Kirsher
2019-10-07 20:48   ` Joe Perches [this message]
2019-10-07 20:48     ` Joe Perches
2019-10-07 21:48     ` Jeff Kirsher
2019-10-07 21:48       ` [Intel-wired-lan] " Jeff Kirsher

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=02fe65d8989ef1d030cf31c7134c574a242afc17.camel@perches.com \
    --to=joe@perches.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=mitch.a.williams@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=patryk.malek@intel.com \
    /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.