Re: [PATCH v2] kbuild: Don't source kernel config

From: Nicolas Pitre
Date: Tue Feb 20 2018 - 11:26:38 EST


On Tue, 20 Feb 2018, Richard Weinberger wrote:

> An alternate approach would be this:
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 5c12dc91ef34..ff0a7c62344b 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -161,6 +161,13 @@ static int conf_set_sym_val(struct symbol *sym, int def,
> int def_flags, char *p)
> case S_STRING:
> if (*p++ != '"')
> break;
> +
> + p2 = strpbrk(p, "`$");
> + if (p2 && !(p2[0] == '$' && p2[1] != '(')) {
> + conf_warning("string contains forbidden characters");
> + return 1;
> + }
> +
> for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
> if (*p2 == '"') {
> *p2 = 0;
>
> That way the conf tool will sanitize the .config before shell scripts will
> source it.

Looks like a much saner approach to me indeed.


Nicolas