2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Fix duplicate detection in sudo_putenv(), do not prune out the

variable we just set when overwriting an existing instance.
Fixes bug #570
This commit is contained in:
Todd C. Miller
2012-09-11 10:22:37 -04:00
parent d2a46c0f81
commit 6beab19148

View File

@@ -324,15 +324,14 @@ sudo_putenv_nodebug(char *str, bool dupcheck, bool overwrite)
break;
}
}
/* Prune out duplicate variables. */
/* Prune out extra instances of the variable we just overwrote. */
if (found && overwrite) {
while (*ep != NULL) {
while (*++ep != NULL) {
if (strncmp(str, *ep, len) == 0) {
char **cur = ep;
while ((*cur = *(cur + 1)) != NULL)
cur++;
} else {
ep++;
ep--;
}
}
env.env_len = ep - env.envp;