From: Todd C. Miller Date: Tue, 11 Sep 2012 14:25:07 +0000 (-0400) Subject: Fix duplicate detection in sudo_putenv(), do not prune out the X-Git-Tag: SUDO_1_7_10p1~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4b906433246766d1e00ab51313209f618c804b9;p=sudo Fix duplicate detection in sudo_putenv(), do not prune out the variable we just set when overwriting an existing instance. Fixes bug #570 --HG-- branch : 1.7 --- diff --git a/env.c b/env.c index ef7d92b8d..c9279b9eb 100644 --- a/env.c +++ b/env.c @@ -497,15 +497,14 @@ sudo_putenv(str, dupcheck, 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;