linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Minor <james.minor@ni.com>
To: <linux-modules@vger.kernel.org>
Cc: <julia.cartwright@ni.com>, <zach.brown@ni.com>,
	<ken.sharp@ni.com>, James Minor <james.minor@ni.com>
Subject: [RFC v1] libkmod: Fix handling of quotes in kernel command line
Date: Fri, 20 Jan 2017 17:15:50 -0600	[thread overview]
Message-ID: <1484954150-12831-1-git-send-email-james.minor@ni.com> (raw)

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>
---
 libkmod/libkmod-config.c | 7 +++++++
 1 file changed, 7 insertions(+)

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';
-- 
1.9.1


             reply	other threads:[~2017-01-20 23:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 23:15 James Minor [this message]
2017-01-23 20:05 ` [RFC v1] libkmod: Fix handling of quotes in kernel command line Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484954150-12831-1-git-send-email-james.minor@ni.com \
    --to=james.minor@ni.com \
    --cc=julia.cartwright@ni.com \
    --cc=ken.sharp@ni.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=zach.brown@ni.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).