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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-02-20 23:32:53 -05:00
parent ccad1fd07c
commit 184d190473
5 changed files with 68 additions and 2 deletions
+5
View File
@@ -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;