diff options
author | Ron Yorston <rmy@pobox.com> | 2018-03-30 12:35:23 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-03-30 12:35:23 +0100 |
commit | e2f7bd0469c8751d9f37d493d395180a61286e94 (patch) | |
tree | 3d25a26f0e61dc2a3928b3080e1b3852b47f664f | |
parent | 99114618463c8e7282f8a3a1825a59ffc2ee4089 (diff) | |
download | busybox-w32-e2f7bd0469c8751d9f37d493d395180a61286e94.tar.gz busybox-w32-e2f7bd0469c8751d9f37d493d395180a61286e94.tar.bz2 busybox-w32-e2f7bd0469c8751d9f37d493d395180a61286e94.zip |
ash: copy environment variables when importing them
Clearing the environment on Microsoft Windows results in pointers
used for shell variables becoming invalid. Take copies when the
environment is imported.
This only affects NOFORK applets invoked by tryexec, but the number
of NOFORK applets has increased considerably in recent years.
-rw-r--r-- | shell/ash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 586925835..2d51b48f9 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -14502,7 +14502,11 @@ init(void) | |||
14502 | * os.execv("ash", [ 'ash', '-c', 'env | grep test-test' ]) # breaks this | 14502 | * os.execv("ash", [ 'ash', '-c', 'env | grep test-test' ]) # breaks this |
14503 | */ | 14503 | */ |
14504 | if (strchr(*envp, '=')) { | 14504 | if (strchr(*envp, '=')) { |
14505 | #if !ENABLE_PLATFORM_MINGW32 | ||
14505 | setvareq(*envp, VEXPORT|VTEXTFIXED); | 14506 | setvareq(*envp, VEXPORT|VTEXTFIXED); |
14507 | #else | ||
14508 | setvareq(*envp, VEXPORT); | ||
14509 | #endif | ||
14506 | } | 14510 | } |
14507 | } | 14511 | } |
14508 | 14512 | ||