From ae6b6b71cdbfb3fb6e1192178fa1e530a2f07ece Mon Sep 17 00:00:00 2001 From: Tomasz Konojacki Date: Tue, 19 Apr 2022 16:41:23 +0200 Subject: make PERL_USE_SAFE_PUTENV the default and the only option Now environ isn't owned by Perl and calling setenv/putenv in XS code will no longer result in memory corruption. Fixes #19399 --- util.c | 96 +++--------------------------------------------------------------- 1 file changed, 4 insertions(+), 92 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 5f9acd7393..f94ba39e8f 100644 --- a/util.c +++ b/util.c @@ -2480,73 +2480,6 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) return; # endif -# ifdef __amigaos4__ - amigaos4_obtain_environ(__FUNCTION__); -# endif - -# ifndef PERL_USE_SAFE_PUTENV - if (!PL_use_safe_putenv) { - /* most putenv()s leak, so we manipulate environ directly */ - UV i; - Size_t vlen, nlen = strlen(nam); - - /* where does it go? */ - for (i = 0; environ[i]; i++) { - if (strnEQ(environ[i], nam, nlen) && environ[i][nlen] == '=') - break; - } - - if (environ == PL_origenviron) { /* need we copy environment? */ - UV j, max; - char **tmpenv; - - max = i; - while (environ[max]) - max++; - - /* XXX shouldn't that be max+1 rather than max+2 ??? - DAPM */ - tmpenv = (char**)S_env_alloc(NULL, max, 2, 0, sizeof(char*)); - - for (j=0; j