free up our cached copy of the passwd structs, including sudo_user
and sudo_runas. Fixes a use-after-free bug.
if (ISSET(sudo_mode, MODE_RUN))
set_perms(PERM_FULL_RUNAS);
- /* Close the password and group files */
- sudo_endpwent();
- sudo_endgrent();
-
if (ISSET(sudo_mode, MODE_LOGIN_SHELL)) {
char *p;
(void) sigaction(SIGTSTP, &saved_sa_tstp, NULL);
(void) sigaction(SIGCHLD, &saved_sa_chld, NULL);
+ /* Close the password and group files and free up memory. */
+ sudo_endpwent();
+ sudo_endgrent();
+
closefrom(def_closefrom + 1);
#ifndef PROFILING
(void) sigaction(SIGQUIT, &saved_sa_quit, NULL);
(void) sigaction(SIGCHLD, &saved_sa_chld, NULL);
set_perms(PERM_FULL_USER);
+ sudo_endpwent();
+ sudo_endgrent();
+ closefrom(def_closefrom + 1);
execvp(nargv[0], nargv);
warning("unable to execute %s", nargv[0]);
_exit(127);