From c02b08e0f33f6dfa5e67dd5dcdd4db6bfee7024d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 26 Jul 2010 12:34:27 -0400 Subject: [PATCH] sudo_pwdup() was not expanding an empty pw_shell to _PATH_BSHELL --HG-- branch : 1.7 --- pwutil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pwutil.c b/pwutil.c index 3bdc88a88..35524f355 100644 --- a/pwutil.c +++ b/pwutil.c @@ -135,7 +135,9 @@ sudo_pwdup(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); @@ -154,7 +156,9 @@ sudo_pwdup(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); } -- 2.40.0