summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorPeter Korsgaard2015-09-09 14:55:07 +0200
committerDenys Vlasenko2015-09-09 14:55:07 +0200
commit875297378cdbebb1278a4595f9fffffca3fc2303 (patch)
tree2a37162c352ee7e7cbd5f9291714e022b4088474 /modutils
parentca25af9b06b0c3ded77ac70087227896b34003c4 (diff)
downloadbusybox-875297378cdbebb1278a4595f9fffffca3fc2303.zip
busybox-875297378cdbebb1278a4595f9fffffca3fc2303.tar.gz
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>
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 996de40..314a7a1 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -348,6 +348,38 @@ static const char *humanly_readable_name(struct module_entry *m)
return m->probed_name ? m->probed_name : m->modname;
}
+/* Like strsep(&stringp, "\n\t ") but quoted text goes to single token
+ * even if it contains whitespace.
+ */
+static char *strsep_quotes(char **stringp)
+{
+ char *s, *start = *stringp;
+
+ if (!start)
+ return NULL;
+
+ for (s = start; ; s++) {
+ switch (*s) {
+ case '"':
+ s = strchrnul(s + 1, '"'); /* find trailing quote */
+ if (*s != '\0')
+ s++; /* skip trailing quote */
+ /* fall through */
+ case '\0':
+ case '\n':
+ case '\t':
+ case ' ':
+ if (*s != '\0') {
+ *s = '\0';
+ *stringp = s + 1;
+ } else {
+ *stringp = NULL;
+ }
+ return start;
+ }
+ }
+}
+
static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename)
{
char *kcmdline_buf;
@@ -359,7 +391,7 @@ static char *parse_and_add_kcmdline_module_options(char *options, const char *mo
return options;
kcmdline = kcmdline_buf;
- while ((kptr = strsep(&kcmdline, "\n\t ")) != NULL) {
+ while ((kptr = strsep_quotes(&kcmdline)) != NULL) {
char *after_modulename = is_prefixed_with(kptr, modulename);
if (!after_modulename || *after_modulename != '.')
continue;