netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xavier Bestel <xavier.bestel@free.fr>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: David Miller <davem@davemloft.net>,
	7eggert@gmx.de, cate@debian.org, 7eggert@elstempel.de,
	mitch.a.williams@intel.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: restrict device names from having whitespace
Date: Fri, 18 Aug 2006 11:32:30 +0200	[thread overview]
Message-ID: <1155893550.7566.77.camel@capoeira> (raw)
In-Reply-To: <1155885446.7566.15.camel@capoeira>

On Fri, 2006-08-18 at 09:17, Xavier Bestel wrote:
> On Fri, 2006-08-18 at 08:11, Stephen Hemminger wrote:
> > Don't allow spaces in network device names because it makes
> > it difficult to provide text interfaces via sysfs.
> 
> Personally I would at least avoid all chars <= ' ', because an interface
> name is meant to be displayed and these control chars do no good on a
> console nor in X.

Something like the following patch (short of a full in-kernel utf8
validator). That said it starts looking like policy in the kernel. Maybe
the "no space in devname" should just be enforced by some userspace
tool, not by the kernel itself ?

	Xav

diff --git a/net/core/dev.c b/net/core/dev.c
index d95e262..906cbf3 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -636,10 +636,23 @@ struct net_device * dev_get_by_flags(uns
  */
 int dev_valid_name(const char *name)
 {
-	return !(*name == '\0' 
-		 || !strcmp(name, ".")
-		 || !strcmp(name, "..")
-		 || strchr(name, '/'));
+	if(!*name)		/* empty string */
+		return 0;
+	if(*name == '.') {	/* . or .. */
+		if(!name[1])
+			return 0;
+		if(name[1] == '.' && !name[2])
+			return 0;
+	}
+	/* control char, space or slash */
+	while(*name) {
+		if(*name == '/')
+			return 0;
+		if(*name <= ' ')
+			return 0;
+		++name;
+	}
+	return 1;
 }
 
 /**



      reply	other threads:[~2006-08-18  9:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6Kd5j-3Y7-3@gated-at.bofh.it>
     [not found] ` <6KdRL-5xP-7@gated-at.bofh.it>
     [not found]   ` <6Ke1p-5N8-7@gated-at.bofh.it>
     [not found]     ` <6KekO-6u0-25@gated-at.bofh.it>
     [not found]       ` <6KeXv-7qe-17@gated-at.bofh.it>
     [not found]         ` <6KfTz-OX-11@gated-at.bofh.it>
     [not found]           ` <6KfTA-OX-15@gated-at.bofh.it>
2006-08-16  0:02             ` bonding: cannot remove certain named devices Bodo Eggert
2006-08-16  0:10               ` David Miller
2006-08-16  6:35                 ` Giacomo A. Catenazzi
2006-08-16 13:38                   ` Bill Nottingham
2006-08-16 13:59                     ` Giacomo A. Catenazzi
2006-08-16 15:11                     ` Bodo Eggert
2006-08-17  7:29                       ` Xavier Bestel
2006-08-17 14:12                         ` Bill Nottingham
2006-08-17 23:23                         ` David Miller
2006-08-18  0:34                           ` Alan Cox
2006-08-18  1:01                             ` David Miller
2006-08-18  2:20                           ` Bill Nottingham
2006-08-19  3:58                             ` Stephen Hemminger
2006-08-18  6:11                               ` [PATCH] net: restrict device names from having whitespace Stephen Hemminger
2006-08-18  6:36                                 ` David Miller
2006-08-18  7:17                                 ` Xavier Bestel
2006-08-18  9:32                                   ` Xavier Bestel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1155893550.7566.77.camel@capoeira \
    --to=xavier.bestel@free.fr \
    --cc=7eggert@elstempel.de \
    --cc=7eggert@gmx.de \
    --cc=cate@debian.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitch.a.williams@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).