]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-config: fix parsing quoted kernel cmdline on params
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 16 Feb 2017 17:18:35 +0000 (09:18 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 16 Feb 2017 17:18:35 +0000 (09:18 -0800)
We can only accept quoted values, not module names or parameter names.

libkmod/libkmod-config.c
testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline5/proc/cmdline

index 18f300ac338ab8abe6abc1eab5f7189771bb7975..aaac0a1393c28ea6dbc309e2c440c92a44eff6a9 100644 (file)
@@ -517,10 +517,24 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config)
        for (p = buf, modname = buf; *p != '\0' && *p != '\n'; p++) {
                if (*p == '"') {
                        is_quoted = !is_quoted;
+
+                       if (is_quoted) {
+                               /* don't consider a module until closing quotes */
+                               is_module = false;
+                       } else if (param != NULL && value != NULL) {
+                               /*
+                                * If we are indeed expecting a value and
+                                * closing quotes, then this can be considered
+                                * a valid option for a module
+                                */
+                               is_module = true;
+                       }
+
                        continue;
                }
                if (is_quoted)
                        continue;
+
                switch (*p) {
                case ' ':
                        *p = '\0';
index 0c796b3e9403f2c99e2b2caceafd12e68e9a1fa1..84e01685804c65ee13c255c40e209bbebc7c594e 100644 (file)
@@ -1 +1 @@
-psmouse.foo psmouse.bar=1 psmouse.foobar="test 1" " notamodule" "noteamodule2 " notamodule3 " quiet rw
+psmouse.foo psmouse.bar=1 psmouse.foobar="test 1" psmouse."invalid option" " notamodule" "noteamodule2 " notamodule3 quiet rw