You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.0 KiB

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