]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: make a copy of the "verb" from argv[] before forking off a child 12055/head
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Mar 2019 17:07:21 +0000 (18:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 21 Mar 2019 17:10:06 +0000 (18:10 +0100)
src/systemctl/systemctl.c

index 9d94935d686c35bc07352e4192d7670bac51b618..9d2115b712127aa045074eabd380a6b0c5577258 100644 (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;