From: Richard Weinberger <richard@nod.at>
To: masahiroy@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH 2/2] kconfig: Deny command substitution in string values
Date: Mon, 20 Sep 2021 23:39:57 +0200 [thread overview]
Message-ID: <20210920213957.1064-2-richard@nod.at> (raw)
In-Reply-To: <20210920213957.1064-1-richard@nod.at>
The post processed .config file will get included in shell
and makefiles. So make sure that a string does not contain
symbols that allow command substitution.
If such a malformed string is found, return empty string
and report it.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/kconfig/symbol.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 4a31bb943f79..1035ecdddc99 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -880,6 +880,11 @@ const char *sym_escape_string(struct symbol *sym)
in = sym_get_string_value(sym);
+ if (strspn(in, "`$")) {
+ fprintf(stderr, "%s: invalid characters in string found\n", sym->name);
+ return xstrdup("\"\"");
+ }
+
reslen = strlen(in) + strlen("\"\"") + 1;
p = in;
--
2.26.2
next prev parent reply other threads:[~2021-09-20 21:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 21:39 [PATCH 1/2] kconfig: Refactor sym_escape_string_value Richard Weinberger
2021-09-20 21:39 ` Richard Weinberger [this message]
2021-09-22 7:17 ` [PATCH 2/2] kconfig: Deny command substitution in string values Boris Kolpackov
2021-09-22 7:27 ` Richard Weinberger
2021-09-22 15:18 ` Boris Kolpackov
2021-09-22 16:17 ` Richard Weinberger
2021-09-25 8:58 ` Masahiro Yamada
2021-09-27 14:34 ` Boris Kolpackov
2021-09-27 12:36 ` [PATCH 1/2] kconfig: Refactor sym_escape_string_value Masahiro Yamada
2021-10-05 15:42 ` Masahiro Yamada
2021-10-07 6:45 ` Richard Weinberger
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=20210920213957.1064-2-richard@nod.at \
--to=richard@nod.at \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/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
all inboxes | Powered by JetHome®