libkmod-config: Only match dot before '=' in /proc/cmdline
authorMichal Marek <mmarek@suse.cz>
Wed, 5 Mar 2014 12:27:41 +0000 (13:27 +0100)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 5 Mar 2014 15:30:52 +0000 (12:30 -0300)
Otherwise, we also parse strings like

  BOOT_IMAGE=/boot/vmlinuz-3.12.12-57.g5f654cf-default

In practice, this is not a problem, because there is no module named
BOOT_IMAGE=/boot/vmlinuz-3. It just disturbs in modprobe -c output.

libkmod/libkmod-config.c

index 4417871..9905d5e 100644 (file)
@@ -523,7 +523,7 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config)
 {
        char buf[KCMD_LINE_SIZE];
        int fd, err;
-       char *p, *modname,  *param = NULL, *value = NULL;
+       char *p, *modname,  *param = NULL, *value = NULL, is_module = 1;
 
        fd = open("/proc/cmdline", O_RDONLY|O_CLOEXEC);
        if (fd < 0) {
@@ -544,9 +544,11 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config)
                switch (*p) {
                case ' ':
                        *p = '\0';
-                       kcmdline_parse_result(config, modname, param, value);
+                       if (is_module)
+                               kcmdline_parse_result(config, modname, param, value);
                        param = value = NULL;
                        modname = p + 1;
+                       is_module = 1;
                        break;
                case '.':
                        if (param == NULL) {
@@ -557,12 +559,15 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config)
                case '=':
                        if (param != NULL)
                                value = p + 1;
+                       else
+                               is_module = 0;
                        break;
                }
        }
 
        *p = '\0';
-       kcmdline_parse_result(config, modname, param, value);
+       if (is_module)
+               kcmdline_parse_result(config, modname, param, value);
 
        return 0;
 }