From: Todd C. Miller Date: Fri, 25 Jun 2010 17:42:50 +0000 (-0400) Subject: In unsetenv(), assign ep in the for loop instead of doing it earlier. X-Git-Tag: SUDO_1_7_3~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26684e3e22a6009cd7130328de5baed95c475a97;p=sudo In unsetenv(), assign ep in the for loop instead of doing it earlier. This version of the code does not change env.envp in between when ep is assigned and when it is used but older versions (e.g. 1.7.2) do. --HG-- branch : 1.7 --- diff --git a/env.c b/env.c index 75466241e..d9df824f5 100644 --- a/env.c +++ b/env.c @@ -356,7 +356,7 @@ int unsetenv(var) const char *var; { - char **ep = env.envp; + char **ep; size_t len; if (env.envp == NULL) @@ -377,7 +377,7 @@ unsetenv(var) #endif len = strlen(var); - while (*ep != NULL) { + for (ep = env.envp; *ep != NULL;) { if (strncmp(var, *ep, len) == 0 && (*ep)[len] == '=') { /* Found it; shift remainder + NULL over by one and update len. */ memmove(ep, ep + 1,