]> 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:22:37 +0000 (10:22 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 11 Sep 2012 14:22:37 +0000 (10:22 -0400)
variable we just set when overwriting an existing instance.
Fixes bug #570

plugins/sudoers/env.c

index 51ee912d220fbaf3003f19c9698c6f24b78b97ec..46a25595656818d5a2211e21b40f9b335ee522f2 100644 (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;