diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-26 15:13:13 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-26 15:13:13 +0100 |
commit | 44f7ab3df3a16c7c866e75122aeb1d46b67b674b (patch) | |
tree | 5c8c58a44506505100fd63979dd6d68dd2df4780 /src/sat.c | |
parent | job ids must not be empty strings (diff) | |
download | sat-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>
Diffstat (limited to '')
-rw-r--r-- | src/sat.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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)))) |