sudo_pwdup() was not expanding an empty pw_shell to _PATH_BSHELL

This commit is contained in:
Todd C. Miller
2010-07-26 12:34:42 -04:00
parent 1eebebeece
commit 4168fcf2dd

View File

@@ -130,7 +130,9 @@ sudo_pwdup(const struct passwd *pw)
#endif
FIELD_SIZE(pw, pw_gecos, gsize);
FIELD_SIZE(pw, pw_dir, dsize);
FIELD_SIZE(pw, pw_shell, ssize);
/* Treat shell specially since we expand "" -> _PATH_BSHELL */
ssize = strlen(pw_shell) + 1;
total += ssize;
if ((cp = malloc(total)) == NULL)
return(NULL);
@@ -149,7 +151,9 @@ sudo_pwdup(const struct passwd *pw)
#endif
FIELD_COPY(pw, newpw, pw_gecos, gsize);
FIELD_COPY(pw, newpw, pw_dir, dsize);
FIELD_COPY(pw, newpw, pw_shell, ssize);
/* Treat shell specially since we expand "" -> _PATH_BSHELL */
memcpy(cp, pw_shell, ssize);
newpw->pw_shell = cp;
return(newpw);
}