From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Jones Subject: Re: [PATCH net-next] sweep the floors and convert some .get_drvinfo routines to strlcpy Date: Mon, 07 Nov 2011 14:14:17 -0800 Message-ID: <4EB85839.8090503@hp.com> References: <20111107215649.95F372900440@tardy> <1320703902.3020.74.camel@bwh-desktop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Rick Jones , netdev@vger.kernel.org, David Dillow , Steffen Klassert , Ion Badulescu , Jay Cliburn , Chris Snook , Michael Chan , Eilon Greenstein , Matt Carlson , Rasesh Mody , Grant Grundler , Ajit Khaparde , Lennert Buytenhek , Stephen Hemminger , Tim Hockin , Jon Mason , Sony Chacko , Anirban Chakraborty , Francois Romieu , Steve Glendinning To: Ben Hutchings Return-path: Received: from g1t0029.austin.hp.com ([15.216.28.36]:48518 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067Ab1KGWOX (ORCPT ); Mon, 7 Nov 2011 17:14:23 -0500 In-Reply-To: <1320703902.3020.74.camel@bwh-desktop> Sender: netdev-owner@vger.kernel.org List-ID: 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 >> >> 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