661545
From c145af2a34a47f357711a2ae97c3d71db8df905f Mon Sep 17 00:00:00 2001
661545
From: Lennart Poettering <lennart@poettering.net>
661545
Date: Thu, 23 Jul 2015 23:47:54 +0200
661545
Subject: [PATCH] process: an empty environment block should be returned as
661545
 such
661545
661545
An empty env block is completely valid, hence return it as such, and
661545
don't turn it into an error.
661545
661545
(cherry picked from commit 03c55bc0b980e2a6aaf6f166a9271ed8ecce2222)
661545
661545
Resolves: #1685648
661545
---
661545
 src/shared/util.c | 8 +++++++-
661545
 1 file changed, 7 insertions(+), 1 deletion(-)
661545
661545
diff --git a/src/shared/util.c b/src/shared/util.c
661545
index 07de902aaf..82c8e433dd 100644
661545
--- a/src/shared/util.c
661545
+++ b/src/shared/util.c
661545
@@ -954,7 +954,13 @@ int get_process_environ(pid_t pid, char **env) {
661545
                         sz += cescape_char(c, outcome + sz);
661545
         }
661545
 
661545
-        outcome[sz] = '\0';
661545
+        if (!outcome) {
661545
+                outcome = strdup("");
661545
+                if (!outcome)
661545
+                        return -ENOMEM;
661545
+        } else
661545
+                outcome[sz] = '\0';
661545
+
661545
         *env = outcome;
661545
         outcome = NULL;
661545