summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-05-26 12:15:42 +0000
committernicm <nicm@openbsd.org>2016-05-26 12:15:42 +0000
commitcbb5bb31002402daf61482694ab2c64dd1f5827d (patch)
tree8cabddbc4aabc4396dcdcbca6922b3bb19a6cd6b
parentImprove and clarify a few bits; with input from jmc@, ok yasuoka, jmc (diff)
downloadwireguard-openbsd-cbb5bb31002402daf61482694ab2c64dd1f5827d.tar.xz
wireguard-openbsd-cbb5bb31002402daf61482694ab2c64dd1f5827d.zip
Just nuke environ instead of trying to unsetenv everything because that
doesn't necessarily work if there is an entry with an empty name.
-rw-r--r--usr.bin/tmux/environ.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/usr.bin/tmux/environ.c b/usr.bin/tmux/environ.c
index 752b3b88433..c4ccd10104a 100644
--- a/usr.bin/tmux/environ.c
+++ b/usr.bin/tmux/environ.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: environ.c,v 1.12 2016/01/19 15:59:12 nicm Exp $ */
+/* $OpenBSD: environ.c,v 1.13 2016/05/26 12:15:42 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
}
}