]> granicus.if.org Git - sudo/commitdiff
Fix duplicate detection in sudo_putenv(), do not prune out the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 11 Sep 2012 14:25:07 +0000 (10:25 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 11 Sep 2012 14:25:07 +0000 (10:25 -0400)
variable we just set when overwriting an existing instance.
Fixes bug #570

--HG--
branch : 1.7

env.c

diff --git a/env.c b/env.c
index ef7d92b8d856ce3e2605eb400c6bef1613a5dc81..c9279b9eb37c8c6a1f02c1556ea493c94bfd9a34 100644 (file)
--- 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;