Commit 10511488 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] more module parameter parsing bugs

We restore the ","s after parsing: if expect to keep pointers to this
stuff, we must not do that.
parent deedc6f8
...@@ -233,6 +233,7 @@ int param_array(const char *name, ...@@ -233,6 +233,7 @@ int param_array(const char *name,
int ret; int ret;
unsigned int count = 0; unsigned int count = 0;
struct kernel_param kp; struct kernel_param kp;
char save;
/* Get the name right for errors. */ /* Get the name right for errors. */
kp.name = name; kp.name = name;
...@@ -247,7 +248,6 @@ int param_array(const char *name, ...@@ -247,7 +248,6 @@ int param_array(const char *name,
/* We expect a comma-separated list of values. */ /* We expect a comma-separated list of values. */
do { do {
int len; int len;
char save;
if (count > max) { if (count > max) {
printk(KERN_ERR "%s: can only take %i arguments\n", printk(KERN_ERR "%s: can only take %i arguments\n",
...@@ -256,18 +256,17 @@ int param_array(const char *name, ...@@ -256,18 +256,17 @@ int param_array(const char *name,
} }
len = strcspn(val, ","); len = strcspn(val, ",");
/* Temporarily nul-terminate and parse */ /* nul-terminate and parse */
save = val[len]; save = val[len];
((char *)val)[len] = '\0'; ((char *)val)[len] = '\0';
ret = set(val, &kp); ret = set(val, &kp);
((char *)val)[len] = save;
if (ret != 0) if (ret != 0)
return ret; return ret;
kp.arg += elemsize; kp.arg += elemsize;
val += len+1; val += len+1;
count++; count++;
} while (val[-1] == ','); } while (save == ',');
if (count < min) { if (count < min) {
printk(KERN_ERR "%s: needs at least %i arguments\n", printk(KERN_ERR "%s: needs at least %i arguments\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment