From: Ben Hutchings <bhutchings@solarflare.com>
To: Rick Jones <raj@tardy.cup.hp.com>
Cc: <netdev@vger.kernel.org>, David Dillow <dave@thedillows.org>,
Steffen Klassert <klassert@mathematik.tu-chemnitz.de>,
Ion Badulescu <ionut@badula.org>,
Jay Cliburn <jcliburn@gmail.com>,
Chris Snook <chris.snook@gmail.com>,
Michael Chan <mchan@broadcom.com>,
Eilon Greenstein <eilong@broadcom.com>,
Matt Carlson <mcarlson@broadcom.com>,
Rasesh Mody <rmody@brocade.com>,
Grant Grundler <grundler@parisc-linux.org>,
Ajit Khaparde <ajit.khaparde@emulex.com>,
Lennert Buytenhek <buytenh@wantstofly.org>,
Stephen Hemminger <shemminger@linux-foundation.org>,
Tim Hockin <thockin@hockin.org>, Jon Mason <jdmason@kudzu.us>,
Sony Chacko <sony.chacko@qlogic.com>,
Anirban Chakraborty <anirban.chakraborty@qlogic.com>,
Francois Romieu <romieu@fr.zoreil.com>,
Steve Glendinning <steve.glendinning@smsc.com>
Subject: Re: [PATCH net-next] sweep the floors and convert some .get_drvinfo routines to strlcpy
Date: Mon, 7 Nov 2011 22:11:42 +0000 [thread overview]
Message-ID: <1320703902.3020.74.camel@bwh-desktop> (raw)
In-Reply-To: <20111107215649.95F372900440@tardy>
On Mon, 2011-11-07 at 13:56 -0800, Rick Jones wrote:
> From: Rick Jones <rick.jones2@hp.com>
>
> Per the mention made by Ben Hutchings that strlcpy is now the preferred
> string copy routine for a .get_drvinfo routine, do a bit of floor
> sweeping and convert some of the as-yet unconverted ethernet drivers to
> it.
[...]
> diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c
> index 972f80e..5e91602 100644
> --- a/drivers/net/ethernet/3com/3c589_cs.c
> +++ b/drivers/net/ethernet/3com/3c589_cs.c
> @@ -468,9 +468,10 @@ static void tc589_reset(struct net_device *dev)
> static void netdev_get_drvinfo(struct net_device *dev,
> struct ethtool_drvinfo *info)
> {
> - strcpy(info->driver, DRV_NAME);
> - strcpy(info->version, DRV_VERSION);
> - sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
> + strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
> + strlcpy(info->version, DRV_VERSION, sizeof(info->version));
> + snprintf(info->bus_info, sizeof(info->bus_info) - 1,
> + "PCMCIA 0x%lx", dev->base_addr);
[...]
snprintf(), like strlcpy(), will always write a null terminator in the
buffer it is given (unless the buffer size is 0). Therefore it is
incorrect to subtract 1 from the actual buffer size.
Ben.
--
Ben Hutchings, Staff 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.
next prev parent reply other threads:[~2011-11-07 22:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-07 21:56 [PATCH net-next] sweep the floors and convert some .get_drvinfo routines to strlcpy Rick Jones
2011-11-07 22:11 ` Ben Hutchings [this message]
2011-11-07 22:14 ` Rick Jones
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=1320703902.3020.74.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=ajit.khaparde@emulex.com \
--cc=anirban.chakraborty@qlogic.com \
--cc=buytenh@wantstofly.org \
--cc=chris.snook@gmail.com \
--cc=dave@thedillows.org \
--cc=eilong@broadcom.com \
--cc=grundler@parisc-linux.org \
--cc=ionut@badula.org \
--cc=jcliburn@gmail.com \
--cc=jdmason@kudzu.us \
--cc=klassert@mathematik.tu-chemnitz.de \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=raj@tardy.cup.hp.com \
--cc=rmody@brocade.com \
--cc=romieu@fr.zoreil.com \
--cc=shemminger@linux-foundation.org \
--cc=sony.chacko@qlogic.com \
--cc=steve.glendinning@smsc.com \
--cc=thockin@hockin.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).