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: <20080922204718.2782b5b6@extreme>
Date:	Mon, 22 Sep 2008 20:47:18 -0700
From:	Stephen Hemminger <shemminger@...tta.com>
To:	David Miller <davem@...emloft.net>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH] net: network device name ifalias support

On Mon, 22 Sep 2008 19:44:23 -0700 (PDT)
David Miller <davem@...emloft.net> wrote:

> From: Stephen Hemminger <shemminger@...tta.com>
> Date: Mon, 22 Sep 2008 17:43:46 -0700
> 
> > +	dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
> > +	if (!dev->ifalias)
> > +		return -ENOMEM;
> > +
> > +	strlcpy(dev->ifalias, alias, len+1);
> > +	return len;
> 
> It might be cleaner to use kstrdup() and free the old pointer, if
> any, here.
> 
> 	char *new = kstrdup(alias, GFP_KERNEL);
> 	if (!new)
> 		return -ENOMEM;
> 	kfree(dev->ifalias);
> 	dev->ifalias = new;
> 	return len;
> 
> That way all of this "len+1" stuff goes away.

Won't work because input string is not necessarily null-terminated.
In the sysfs case we want there is a trailing newline, and this
way avoids copying once there and then copying again.
--
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