From: Milosz Tanski Date: Tue, 5 Aug 2008 18:33:02 +0000 (-0400) Subject: Safer environ iteration X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9d27dca99b7a70de3c674d084792e402944a2c0c;p=p5sagit%2Fp5-mst-13.2.git Safer environ iteration From: "Milosz Tanski" Message-ID: p4raw-id: //depot/perl@34225 --- diff --git a/perl.c b/perl.c index 0698996..e41ae96 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); }