summaryrefslogtreecommitdiffstats
path: root/environ.c
diff options
context:
space:
mode:
authornicm <nicm>2016-05-26 12:15:42 +0000
committernicm <nicm>2016-05-26 12:15:42 +0000
commitcd14ac0486906d607b5ef6ade70460c64aec00cf (patch)
treed0bd87eb9b3c3773ae8e1d2a4e197da959f1a5ed /environ.c
parent95a4cc3bcef95feb6dfca7557cef4c32a424e4d4 (diff)
Just nuke environ instead of trying to unsetenv everything because that
doesn't necessarily work if there is an entry with an empty name.
Diffstat (limited to 'environ.c')
-rw-r--r--environ.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/environ.c b/environ.c
index d855f8b5..31e57e0e 100644
--- a/environ.c
+++ b/environ.c
@@ -195,19 +195,11 @@ environ_update(const char *vars, struct environ *srcenv,
void
environ_push(struct environ *env)
{
- struct environ_entry *envent;
- char *v;
-
- while (*environ != NULL) {
- v = xstrdup(*environ);
- v[strcspn(v, "=")] = '\0';
-
- unsetenv(v);
- free(v);
- }
+ struct environ_entry *envent;
+ environ = xcalloc(1, sizeof *environ);
RB_FOREACH(envent, environ, env) {
- if (envent->value != NULL)
+ if (envent->value != NULL && *envent->name != '\0')
setenv(envent->name, envent->value, 1);
}
}