]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
bonding: fix parameter parsing
authorJay Vosburgh <fubar@us.ibm.com>
Wed, 30 Jan 2008 02:07:43 +0000 (18:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Feb 2008 12:28:11 +0000 (04:28 -0800)
My last fix (commit ece95f7fefe3afae19e641e1b3f5e64b00d5b948)
didn't handle one case correctly.  This resolves that, and it will now
correctly parse parameters with arbitrary white space, and either text
names or mode values.

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c

index 2039f7838f2df713a0afe9a4bbe1aecc8955e617..2766855a5aeec1f96502d3cdcf021df87a6ace2b 100644 (file)
@@ -4549,14 +4549,19 @@ static void bond_free_all(void)
 int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl)
 {
        int mode = -1, i, rv;
-       char modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, };
+       char *p, modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, };
 
-       rv = sscanf(buf, "%d", &mode);
-       if (!rv) {
+       for (p = (char *)buf; *p; p++)
+               if (!(isdigit(*p) || isspace(*p)))
+                       break;
+
+       if (*p)
                rv = sscanf(buf, "%20s", modestr);
-               if (!rv)
-                       return -1;
-       }
+       else
+               rv = sscanf(buf, "%d", &mode);
+
+       if (!rv)
+               return -1;
 
        for (i = 0; tbl[i].modename; i++) {
                if (mode == tbl[i].mode)