aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-30 12:35:23 +0100
committerRon Yorston <rmy@pobox.com>2018-03-30 12:35:23 +0100
commite2f7bd0469c8751d9f37d493d395180a61286e94 (patch)
tree3d25a26f0e61dc2a3928b3080e1b3852b47f664f
parent99114618463c8e7282f8a3a1825a59ffc2ee4089 (diff)
downloadbusybox-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.c4
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