[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4EB85839.8090503@hp.com>
Date: Mon, 07 Nov 2011 14:14:17 -0800
From: Rick Jones <rick.jones2@...com>
To: Ben Hutchings <bhutchings@...arflare.com>
CC: Rick Jones <raj@...dy.cup.hp.com>, netdev@...r.kernel.org,
David Dillow <dave@...dillows.org>,
Steffen Klassert <klassert@...hematik.tu-chemnitz.de>,
Ion Badulescu <ionut@...ula.org>,
Jay Cliburn <jcliburn@...il.com>,
Chris Snook <chris.snook@...il.com>,
Michael Chan <mchan@...adcom.com>,
Eilon Greenstein <eilong@...adcom.com>,
Matt Carlson <mcarlson@...adcom.com>,
Rasesh Mody <rmody@...cade.com>,
Grant Grundler <grundler@...isc-linux.org>,
Ajit Khaparde <ajit.khaparde@...lex.com>,
Lennert Buytenhek <buytenh@...tstofly.org>,
Stephen Hemminger <shemminger@...ux-foundation.org>,
Tim Hockin <thockin@...kin.org>, Jon Mason <jdmason@...zu.us>,
Sony Chacko <sony.chacko@...gic.com>,
Anirban Chakraborty <anirban.chakraborty@...gic.com>,
Francois Romieu <romieu@...zoreil.com>,
Steve Glendinning <steve.glendinning@...c.com>
Subject: Re: [PATCH net-next] sweep the floors and convert some .get_drvinfo
routines to strlcpy
On 11/07/2011 02:11 PM, Ben Hutchings wrote:
> On Mon, 2011-11-07 at 13:56 -0800, Rick Jones wrote:
>> From: Rick Jones<rick.jones2@...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.
I will fix those and resend. Thanks.
rick jones
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists