lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1320703902.3020.74.camel@bwh-desktop>
Date:	Mon, 7 Nov 2011 22:11:42 +0000
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Rick Jones <raj@...dy.cup.hp.com>
CC:	<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 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.

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.

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ