From 9d27dca99b7a70de3c674d084792e402944a2c0c Mon Sep 17 00:00:00 2001 From: Milosz Tanski Date: Tue, 5 Aug 2008 14:33:02 -0400 Subject: Safer environ iteration From: "Milosz Tanski" Message-ID: p4raw-id: //depot/perl@34225 --- perl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'perl.c') diff --git a/perl.c b/perl.c index 0698996b1a..e41ae96292 100644 --- a/perl.c +++ b/perl.c @@ -4671,18 +4671,21 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register environ[0] = NULL; } if (env) { - char *s; + char *s, *old_var; SV *sv; for (; *env; env++) { - if (!(s = strchr(*env,'=')) || s == *env) + old_var = *env; + + if (!(s = strchr(old_var,'=')) || s == old_var) continue; + #if defined(MSDOS) && !defined(DJGPP) *s = '\0'; - (void)strupr(*env); + (void)strupr(old_var); *s = '='; #endif sv = newSVpv(s+1, 0); - (void)hv_store(hv, *env, s - *env, sv, 0); + (void)hv_store(hv, old_var, s - old_var, sv, 0); if (env_is_not_environ) mg_set(sv); } -- cgit v1.2.1