diff options
author | Ron Yorston <rmy@pobox.com> | 2022-05-05 15:14:10 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-05-05 15:14:10 +0100 |
commit | 3b5042430fc4b82d44e0430f9ecc21a9228d1651 (patch) | |
tree | 192bbe0db34239cbc927ddeece00162584bca2d4 /win32/env.c | |
parent | 9e535b09a70a1ef7a2260e6d6955f7bbf291a08f (diff) | |
download | busybox-w32-3b5042430fc4b82d44e0430f9ecc21a9228d1651.tar.gz busybox-w32-3b5042430fc4b82d44e0430f9ecc21a9228d1651.tar.bz2 busybox-w32-3b5042430fc4b82d44e0430f9ecc21a9228d1651.zip |
win32: better fix for empty environment variables
It appears the CRT and OS each have a copy of the environment.
mingw_putenv() fools the CRT into accepting an empty environment
variable by calling _putenv("V=0") then truncating the new value
by hand. But _putenv() also updates the OS environment with the
fake 'V=0' value. Commit 5b48ca53b (win32: pass NULL to spawnve,
not environ) resulted in this fake value being used and hence empty
variables getting the value '0'.
- Add a call to SetEnvironmentVariable() in mingw_putenv() to update
the OS environment.
- Restore the use of NULL environment pointers in mingw_spawnvp().
- Add a test.
(GitHub issue #250)
Diffstat (limited to 'win32/env.c')
-rw-r--r-- | win32/env.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/env.c b/win32/env.c index 4d4e9c8fd..8e54c4c5e 100644 --- a/win32/env.c +++ b/win32/env.c | |||
@@ -100,6 +100,10 @@ int mingw_putenv(const char *env) | |||
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | |||
104 | /* tell the OS environment about the change */ | ||
105 | envstr[s - env] = '\0'; | ||
106 | SetEnvironmentVariable(envstr, ""); | ||
103 | free(envstr); | 107 | free(envstr); |
104 | } | 108 | } |
105 | 109 | ||