From: Ben Hutchings <bhutchings@solarflare.com>
To: Sasikanth V <sasikanth.v19@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] Fix overflow of name in struct net_device, replaced str* and sprintf with strn* and snprintf respectivly.
Date: Tue, 15 Mar 2011 15:32:56 +0000 [thread overview]
Message-ID: <1300203176.2758.0.camel@bwh-desktop> (raw)
In-Reply-To: <AANLkTi=g2rczjMAyz788np+frUvWCBuRWDt1Px+ZAM6D@mail.gmail.com>
On Tue, 2011-03-15 at 20:30 +0530, Sasikanth V wrote:
> On Tue, Mar 15, 2011 at 1:59 AM, Ben Hutchings
> <bhutchings@solarflare.com> wrote:
> On Tue, 2011-03-15 at 01:37 +0530, Sasikanth V wrote:
> > Signed-off-by: Sasikanth V <sasikanth.v19@gmail.com>
> > ---
> > net/core/dev.c | 14 +++++++-------
> > 1 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index 6561021..9d06c1e 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -510,7 +510,7 @@ int netdev_boot_setup_check(struct
> net_device *dev)
> >
> > for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
> > if (s[i].name[0] != '\0' && s[i].name[0] != '
> ' &&
> > - !strcmp(dev->name, s[i].name)) {
> > + !strncmp(dev->name, s[i].name, IFNAMSIZ))
> {
>
>
> If s[i].name is too long, so what? No change is required
> here.
>
> > dev->irq = s[i].map.irq;
> > dev->base_addr = s[i].map.base_addr;
> > dev->mem_start = s[i].map.mem_start;
> > @@ -539,7 +539,7 @@ unsigned long netdev_boot_base(const
> char *prefix, int unit)
> > char name[IFNAMSIZ];
> > int i;
> >
> > - sprintf(name, "%s%d", prefix, unit);
> > + snprintf(name, IFNAMSIZ, "%s%d", prefix, unit);
>
>
> This looks reasonable.
>
> > /*
> > * If device already registered then return base of 1
> > @@ -549,7 +549,7 @@ unsigned long netdev_boot_base(const
> char *prefix, int unit)
> > return 1;
> >
> > for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
> > - if (!strcmp(name, s[i].name))
> > + if (!strncmp(name, s[i].name, IFNAMSIZ))
>
>
> Not required.
>
> So, Do we have to remove already existing strncmp (to compare
> the device name) in dev.c?
[...]
I don't know what you mean.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
prev parent reply other threads:[~2011-03-15 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-14 20:07 [PATCH] Fix overflow of name in struct net_device, replaced str* and sprintf with strn* and snprintf respectivly Sasikanth V
2011-03-14 20:29 ` Ben Hutchings
[not found] ` <AANLkTi=g2rczjMAyz788np+frUvWCBuRWDt1Px+ZAM6D@mail.gmail.com>
2011-03-15 15:32 ` Ben Hutchings [this message]
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=1300203176.2758.0.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sasikanth.v19@gmail.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 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).