From 66b1d5575fd5eb6242bac2e9a08b163be8b1b960 Mon Sep 17 00:00:00 2001 From: Hans Mulder Date: Thu, 29 May 1997 20:30:44 +1200 Subject: ENV leaks on win32 (was Re: Comments on ENV patch sought) Subject: [PATCH] for NETaa13787: %ENV=(); doesn't clear the environment Perl maintains two representations of the environment: (A) a hash named %ENV, used by the perl script (B) a char** named environ, which is passed to child processes Obviously, the intent is to keep tho two in sync. This fails in two situations: (1) A list assignment to %ENV clears (A) but not (B); (2) Assigning to $0 has the side effect of deleting the key NoNeSuCh form (B) but not from (A). $ perl -e '%ENV=(); print "home\n" if exists $ENV{HOME}; exec "echo \$HOME";' /Users/hansm $ perl -e '$ENV{NoNeSuCh} = "foo"; $0 = "bar"; exec "echo \$NoNeSuCh";' $ perl -e '$ENV{NoNeSuCh} = "foo"; exec "echo \$NoNeSuCh";' foo $ I've complained about rpoblem (1) before; and Larry assigned it bug ID NETaa13787 when he entered it into DDTS. The patch below attempts to remedy both problems, at least on Unix platforms. I don't know how to handle the environment on VMS and WIN32; my code simply calls DIE('unimplemented"), which is honest but won't make users on those plaforms happy. p5p-msgid: 199705292240.AAA01135@mail.euronet.nl Signed-off-by: Peter Prymmer --- perl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perl.h') diff --git a/perl.h b/perl.h index 77ffb53841..6b2e66d523 100644 --- a/perl.h +++ b/perl.h @@ -1927,7 +1927,8 @@ EXT MGVTBL vtbl_sv = {magic_get, magic_set, magic_len, 0, 0}; -EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0}; +EXT MGVTBL vtbl_env = {0, 0, 0, magic_clear_all_env, + 0}; EXT MGVTBL vtbl_envelem = {0, magic_setenv, 0, magic_clearenv, 0}; -- cgit v1.2.1