]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[NET]: Disallow whitespace in network device names.
authorDavid S. Miller <davem@sunset.davemloft.net>
Tue, 15 Aug 2006 23:34:13 +0000 (16:34 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 17 Aug 2006 23:29:56 +0000 (16:29 -0700)
It causes way too much trouble and confusion in userspace.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 9fe96cde3e1956e57dcfca598d74b3bb63530333..d4a1ec3bded5f6afa92c0cbb860101b509f0f338 100644 (file)
 #include <linux/audit.h>
 #include <linux/dmaengine.h>
 #include <linux/err.h>
+#include <linux/ctype.h>
 
 /*
  *     The list of packet types we will receive (as opposed to discard)
@@ -632,14 +633,22 @@ struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mas
  *     @name: name string
  *
  *     Network device names need to be valid file names to
- *     to allow sysfs to work
+ *     to allow sysfs to work.  We also disallow any kind of
+ *     whitespace.
  */
 int dev_valid_name(const char *name)
 {
-       return !(*name == '\0' 
-                || !strcmp(name, ".")
-                || !strcmp(name, "..")
-                || strchr(name, '/'));
+       if (*name == '\0')
+               return 0;
+       if (!strcmp(name, ".") || !strcmp(name, ".."))
+               return 0;
+
+       while (*name) {
+               if (*name == '/' || isspace(*name))
+                       return 0;
+               name++;
+       }
+       return 1;
 }
 
 /**