2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-01 23:05:17 +00:00

Add back allocation of the env struct in rebuild_env but save

a copy of the old pointer and free it before returning.
This commit is contained in:
Todd C. Miller
2007-07-29 22:32:47 +00:00
parent 2304e1a4a7
commit 4b257e50c1

7
env.c
View File

@@ -456,7 +456,7 @@ rebuild_env(sudo_mode, noexec)
int sudo_mode; int sudo_mode;
int noexec; int noexec;
{ {
char **ep, *cp, *ps1; char **old_envp, **ep, *cp, *ps1;
char idbuf[MAX_UID_T_LEN]; char idbuf[MAX_UID_T_LEN];
unsigned int didvar; unsigned int didvar;
@@ -465,6 +465,10 @@ rebuild_env(sudo_mode, noexec)
*/ */
ps1 = NULL; ps1 = NULL;
didvar = 0; 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) { if (def_env_reset) {
/* Pull in vars we want to keep from the old environment. */ /* Pull in vars we want to keep from the old environment. */
for (ep = environ; *ep; ep++) { for (ep = environ; *ep; ep++) {
@@ -657,6 +661,7 @@ rebuild_env(sudo_mode, noexec)
/* Install new environment. */ /* Install new environment. */
environ = env.envp; environ = env.envp;
efree(old_envp);
} }
void void