From: Jim Meyering Date: Wed, 10 Dec 1997 10:25:46 +0000 (+0000) Subject: (main): Make sure pw->pw_shell is non-NULL before trying to strdup it. X-Git-Tag: v2.22-rc1~347^2~10^2~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb677c2efba91a27ac3c93f1d68a2833e02ce436;p=thirdparty%2Futil-linux.git (main): Make sure pw->pw_shell is non-NULL before trying to strdup it. Patch from Dick Streefland. --- diff --git a/login-utils/su.c b/login-utils/su.c index 108d06239d..dda02fe09a 100644 --- a/login-utils/su.c +++ b/login-utils/su.c @@ -530,6 +530,10 @@ main (int argc, char **argv) error (1, 0, _("user %s does not exist"), new_user); endpwent (); + /* make sure pw->pw_shell is non-zero */ + if (pw->pw_shell == 0 || pw->pw_shell[0] == 0) + pw->pw_shell = (char *) DEFAULT_SHELL; + /* Make a copy of the password information and point pw at the local copy instead. Otherwise, some systems (e.g. Linux) would clobber the static data through the getlogin call from log_su. */ @@ -553,8 +557,6 @@ main (int argc, char **argv) } #endif - if (pw->pw_shell == 0 || pw->pw_shell[0] == 0) - pw->pw_shell = (char *) DEFAULT_SHELL; if (shell == 0 && change_environment == 0) shell = getenv ("SHELL"); if (shell != 0 && getuid () && restricted_shell (pw->pw_shell))