mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-30 22:05:46 +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:
7
env.c
7
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
|
||||
|
Reference in New Issue
Block a user