]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process: an empty environment block should be returned as such 694/head
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 21:47:54 +0000 (23:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 21:47:54 +0000 (23:47 +0200)
An empty env block is completely valid, hence return it as such, and
don't turn it into an error.

src/basic/process-util.c

index 66395b7de9e6437f301223f405a47fe7ccbf6547..61f188467f8a15e4afe439a6c34f523a065855cc 100644 (file)
@@ -351,10 +351,13 @@ int get_process_environ(pid_t pid, char **env) {
                         sz += cescape_char(c, outcome + sz);
         }
 
-        if (sz == 0)
-                return -ENOENT;
+        if (!outcome) {
+                outcome = strdup("");
+                if (!outcome)
+                        return -ENOMEM;
+        } else
+                outcome[sz] = '\0';
 
-        outcome[sz] = '\0';
         *env = outcome;
         outcome = NULL;