aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-26 15:13:13 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-26 15:13:13 +0100
commit44f7ab3df3a16c7c866e75122aeb1d46b67b674b (patch)
tree5c8c58a44506505100fd63979dd6d68dd2df4780
parentjob ids must not be empty strings (diff)
downloadsat-44f7ab3df3a16c7c866e75122aeb1d46b67b674b.tar.gz
sat-44f7ab3df3a16c7c866e75122aeb1d46b67b674b.tar.bz2
sat-44f7ab3df3a16c7c866e75122aeb1d46b67b674b.tar.xz
remove empty environment entires
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--src/sat.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sat.c b/src/sat.c
index f84d44b..84140a4 100644
--- a/src/sat.c
+++ b/src/sat.c
@@ -70,6 +70,9 @@ main(int argc, char *argv[], char *envp[])
struct timespec ts;
clockid_t clk;
char *msg = NULL;
+ char *w;
+ char *r;
+ int removed_empty = 0;
size_t n;
if ((argc < 3) || (argv[1][0] == '-')) {
@@ -104,6 +107,18 @@ main(int argc, char *argv[], char *envp[])
argc -= 2;
argv += 2;
+ /* Remove empty environment entries */
+ for (w = r = envp; *r; *r++) {
+ if (**r) {
+ *w++ = *r;
+ } else if (removed_empty == 0) {
+ fprintf(stderr,
+ "%s: warning: removed empty "
+ "environment entry.\n", argv0);
+ removed_empty = 0;
+ }
+ }
+
/* Construct message to send to the daemon. */
n = measure_array(argv) + measure_array(envp);
if (!(msg = malloc(n + sizeof(clk) + sizeof(ts))))