systemctl: make a copy of the "verb" from argv[] before forking off a child

This commit is contained in:
Lennart Poettering
2019-03-21 18:10:06 +01:00
parent a0c6f3cb66
commit 8d1ee64829
+8 -2
View File
@@ -6356,7 +6356,7 @@ static int enable_sysv_units(const char *verb, char **args) {
NULL,
};
_cleanup_free_ char *p = NULL, *q = NULL, *l = NULL;
_cleanup_free_ char *p = NULL, *q = NULL, *l = NULL, *v = NULL;
bool found_native = false, found_sysv;
const char *name;
unsigned c = 1;
@@ -6405,7 +6405,13 @@ static int enable_sysv_units(const char *verb, char **args) {
argv[c++] = q;
}
argv[c++] = verb;
/* Let's copy the verb, since it's still pointing directly into the original argv[] array we
* got passed, but safe_fork() is likely going to rewrite that for the new child */
v = strdup(verb);
if (!v)
return log_oom();
argv[c++] = v;
argv[c++] = basename(p);
argv[c] = NULL;