aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Minor <james.minor@ni.com>2017-01-20 17:15:50 -0600
committerLucas De Marchi <lucas.demarchi@intel.com>2017-01-23 10:47:13 -0800
commitf27a2b12748b55abdbdeba6ec3976033bd257947 (patch)
tree3eb26cf0536211420ae987f4145d16f7e2dd449a
parent67d1534318a59a2e97c077a20471e69e1eeb73c3 (diff)
downloadkmod-f27a2b12748b55abdbdeba6ec3976033bd257947.tar.gz
libkmod: Fix handling of quotes in kernel command line
If a module parameter on the command line contains quotes, any spaces inside those quotes should be included as part of the parameter. Signed-off-by: James Minor <james.minor@ni.com>
-rw-r--r--libkmod/libkmod-config.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 19f56a7..0596025 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -497,6 +497,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, is_module = 1;
+ bool is_quoted = false;
fd = open("/proc/cmdline", O_RDONLY|O_CLOEXEC);
if (fd < 0) {
@@ -514,6 +515,12 @@ 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;
+ continue;
+ }
+ if (is_quoted)
+ continue;
switch (*p) {
case ' ':
*p = '\0';