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: FILEUTILS-3_16g~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cd84da3a607381b666856481c3feb7d9161b706;p=thirdparty%2Fcoreutils.git (main): Make sure pw->pw_shell is non-NULL before trying to strdup it. Patch from Dick Streefland. --- diff --git a/src/su.c b/src/su.c index 108d06239d..dda02fe09a 100644 --- a/src/su.c +++ b/src/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))