Netdev List
 help / color / mirror / Atom feed
* [PATCH] netdev: change name length
@ 2006-08-11 22:13 Stephen Hemminger
  2006-08-11 23:42 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2006-08-11 22:13 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

Some improvements to robust name interface.  These API's are safe
now by convention, but it is worth providing some safety checks
against future bugs.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

---
 net/core/dev.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- net-2.6.19.orig/net/core/dev.c
+++ net-2.6.19/net/core/dev.c
@@ -636,7 +636,8 @@ struct net_device * dev_get_by_flags(uns
  */
 int dev_valid_name(const char *name)
 {
-	return !(*name == '\0' 
+	return !(*name == '\0'
+		 || strlen(name) >= IFNAMSIZ
 		 || !strcmp(name, ".")
 		 || !strcmp(name, "..")
 		 || strchr(name, '/'));
@@ -3198,13 +3199,15 @@ struct net_device *alloc_netdev(int size
 	struct net_device *dev;
 	int alloc_size;
 
+	BUG_ON(strlen(name) >= sizeof(dev->name));
+
 	/* ensure 32-byte alignment of both the device and private area */
 	alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
 	alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
 
 	p = kzalloc(alloc_size, GFP_KERNEL);
 	if (!p) {
-		printk(KERN_ERR "alloc_dev: Unable to allocate device.\n");
+		printk(KERN_ERR "alloc_netdev: Unable to allocate device.\n");
 		return NULL;
 	}
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] netdev: change name length
  2006-08-11 22:13 [PATCH] netdev: change name length Stephen Hemminger
@ 2006-08-11 23:42 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2006-08-11 23:42 UTC (permalink / raw)
  To: shemminger; +Cc: netdev

From: Stephen Hemminger <shemminger@osdl.org>
Date: Fri, 11 Aug 2006 15:13:29 -0700

> Some improvements to robust name interface.  These API's are safe
> now by convention, but it is worth providing some safety checks
> against future bugs.
> 
> Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

Applied, thanks Stephen.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-11 23:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-11 22:13 [PATCH] netdev: change name length Stephen Hemminger
2006-08-11 23:42 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox