diff options
-rw-r--r-- | net/core/dev.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 9fe96cde3e19..d4a1ec3bded5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -116,6 +116,7 @@ | |||
116 | #include <linux/audit.h> | 116 | #include <linux/audit.h> |
117 | #include <linux/dmaengine.h> | 117 | #include <linux/dmaengine.h> |
118 | #include <linux/err.h> | 118 | #include <linux/err.h> |
119 | #include <linux/ctype.h> | ||
119 | 120 | ||
120 | /* | 121 | /* |
121 | * The list of packet types we will receive (as opposed to discard) | 122 | * 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 | |||
632 | * @name: name string | 633 | * @name: name string |
633 | * | 634 | * |
634 | * Network device names need to be valid file names to | 635 | * Network device names need to be valid file names to |
635 | * to allow sysfs to work | 636 | * to allow sysfs to work. We also disallow any kind of |
637 | * whitespace. | ||
636 | */ | 638 | */ |
637 | int dev_valid_name(const char *name) | 639 | int dev_valid_name(const char *name) |
638 | { | 640 | { |
639 | return !(*name == '\0' | 641 | if (*name == '\0') |
640 | || !strcmp(name, ".") | 642 | return 0; |
641 | || !strcmp(name, "..") | 643 | if (!strcmp(name, ".") || !strcmp(name, "..")) |
642 | || strchr(name, '/')); | 644 | return 0; |
645 | |||
646 | while (*name) { | ||
647 | if (*name == '/' || isspace(*name)) | ||
648 | return 0; | ||
649 | name++; | ||
650 | } | ||
651 | return 1; | ||
643 | } | 652 | } |
644 | 653 | ||
645 | /** | 654 | /** |