diff options
author | Peter Korsgaard <peter@korsgaard.com> | 2015-09-09 14:55:07 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-09-09 14:55:07 +0200 |
commit | 875297378cdbebb1278a4595f9fffffca3fc2303 (patch) | |
tree | 2a37162c352ee7e7cbd5f9291714e022b4088474 | |
parent | ca25af9b06b0c3ded77ac70087227896b34003c4 (diff) | |
download | busybox-w32-875297378cdbebb1278a4595f9fffffca3fc2303.tar.gz busybox-w32-875297378cdbebb1278a4595f9fffffca3fc2303.tar.bz2 busybox-w32-875297378cdbebb1278a4595f9fffffca3fc2303.zip |
modprobe: handle module arguments containing spaces
Modprobe wasn't correctly parsing module arguments containing spaces from
/proc/cmdline - E.G. module.property="some text".
Extend the parsing to correctly handle quoted text.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | modutils/modprobe.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 996de4074..314a7a1cb 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -348,6 +348,38 @@ static const char *humanly_readable_name(struct module_entry *m) | |||
348 | return m->probed_name ? m->probed_name : m->modname; | 348 | return m->probed_name ? m->probed_name : m->modname; |
349 | } | 349 | } |
350 | 350 | ||
351 | /* Like strsep(&stringp, "\n\t ") but quoted text goes to single token | ||
352 | * even if it contains whitespace. | ||
353 | */ | ||
354 | static char *strsep_quotes(char **stringp) | ||
355 | { | ||
356 | char *s, *start = *stringp; | ||
357 | |||
358 | if (!start) | ||
359 | return NULL; | ||
360 | |||
361 | for (s = start; ; s++) { | ||
362 | switch (*s) { | ||
363 | case '"': | ||
364 | s = strchrnul(s + 1, '"'); /* find trailing quote */ | ||
365 | if (*s != '\0') | ||
366 | s++; /* skip trailing quote */ | ||
367 | /* fall through */ | ||
368 | case '\0': | ||
369 | case '\n': | ||
370 | case '\t': | ||
371 | case ' ': | ||
372 | if (*s != '\0') { | ||
373 | *s = '\0'; | ||
374 | *stringp = s + 1; | ||
375 | } else { | ||
376 | *stringp = NULL; | ||
377 | } | ||
378 | return start; | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | |||
351 | static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename) | 383 | static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename) |
352 | { | 384 | { |
353 | char *kcmdline_buf; | 385 | char *kcmdline_buf; |
@@ -359,7 +391,7 @@ static char *parse_and_add_kcmdline_module_options(char *options, const char *mo | |||
359 | return options; | 391 | return options; |
360 | 392 | ||
361 | kcmdline = kcmdline_buf; | 393 | kcmdline = kcmdline_buf; |
362 | while ((kptr = strsep(&kcmdline, "\n\t ")) != NULL) { | 394 | while ((kptr = strsep_quotes(&kcmdline)) != NULL) { |
363 | char *after_modulename = is_prefixed_with(kptr, modulename); | 395 | char *after_modulename = is_prefixed_with(kptr, modulename); |
364 | if (!after_modulename || *after_modulename != '.') | 396 | if (!after_modulename || *after_modulename != '.') |
365 | continue; | 397 | continue; |