diff options
| -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; |
