From: Todd C. Miller Date: Sun, 29 Jul 2007 22:32:47 +0000 (+0000) Subject: Add back allocation of the env struct in rebuild_env but save X-Git-Tag: SUDO_1_7_0~458 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b257e50c15c61ff943c8df15c85d7d8d696a8e8;p=sudo Add back allocation of the env struct in rebuild_env but save a copy of the old pointer and free it before returning. --- diff --git a/env.c b/env.c index 7ef93c801..0d5468f4d 100644 --- a/env.c +++ b/env.c @@ -456,7 +456,7 @@ rebuild_env(sudo_mode, noexec) int sudo_mode; int noexec; { - char **ep, *cp, *ps1; + char **old_envp, **ep, *cp, *ps1; char idbuf[MAX_UID_T_LEN]; unsigned int didvar; @@ -465,6 +465,10 @@ rebuild_env(sudo_mode, noexec) */ ps1 = NULL; didvar = 0; + env.env_len = 0; + env.env_size = 128; + old_envp = env.envp; + env.envp = emalloc2(env.env_size, sizeof(char *)); if (def_env_reset) { /* Pull in vars we want to keep from the old environment. */ for (ep = environ; *ep; ep++) { @@ -657,6 +661,7 @@ rebuild_env(sudo_mode, noexec) /* Install new environment. */ environ = env.envp; + efree(old_envp); } void