From 184d19047370652184a44686cf85bf5001bdf413 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 17 Feb 2017 22:56:28 -0500 Subject: Tighten checking for variable validity In the future we might want to allow additional syntax (for example "unset VAR". But let's check that the data we're getting does not contain anything unexpected. --- src/basic/exec-util.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/basic/exec-util.c') diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index 207fac8dc1..aced9e8e3d 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -279,6 +279,11 @@ static int gather_environment_generate(int fd, void *arg) { STRV_FOREACH_PAIR(x, y, new) { char *p; + if (!env_name_is_valid(*x)) { + log_warning("Invalid variable assignment \"%s=...\", ignoring.", *x); + continue; + } + p = strjoin(*x, "=", *y); if (!p) return -ENOMEM; -- cgit v1.2.3-54-g00ecf