patch-2.3.99-pre6 linux/net/decnet/sysctl_net_decnet.c

Next file: linux/net/econet/af_econet.c
Previous file: linux/net/decnet/af_decnet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre5/linux/net/decnet/sysctl_net_decnet.c linux/net/decnet/sysctl_net_decnet.c
@@ -54,6 +54,22 @@
 #define ISALPHA(x) (ISLOWER(x) || ISUPPER(x))
 #define INVALID_END_CHAR(x) (ISNUM(x) || ISALPHA(x))
 
+static void strip_it(char *str)
+{
+	for(;;) {
+		switch(*str) {
+			case ' ':
+			case '\n':
+			case '\r':
+			case ':':
+				*str = 0;
+			case 0:
+				return;
+		}
+		str++;
+	}
+}
+
 /*
  * Simple routine to parse an ascii DECnet address
  * into a network order address.
@@ -159,8 +175,9 @@
 			return -EFAULT;
 
 		addr[len] = 0;
+		strip_it(addr);
 
-		if (parse_addr(&dnaddr, buffer))
+		if (parse_addr(&dnaddr, addr))
 			return -EINVAL;
 
 		dn_dev_devices_off();
@@ -257,8 +274,6 @@
 	}
 
 	if (write) {
-		int i;
-
 		if (*lenp > 16)
 			return -E2BIG;
 
@@ -266,9 +281,7 @@
 			return -EFAULT;
 
 		devname[*lenp] = 0;
-		for(i = 0; i < (*lenp); i++)
-			if (devname[i] == '\n')
-				devname[i] = 0;
+		strip_it(devname);
 
 		if ((dev = __dev_get_by_name(devname)) == NULL)
 			return -ENODEV;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)