diff options
author | Jim Meyering <jim@meyering.net> | 1997-12-10 10:25:46 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1997-12-10 10:25:46 +0000 |
commit | 3cd84da3a607381b666856481c3feb7d9161b706 (patch) | |
tree | 04c42a172aaa5a5740415709e989cd184d33fa96 | |
parent | 92f0098844fc806a94a3e1256dfa28137758d900 (diff) | |
download | coreutils-3cd84da3a607381b666856481c3feb7d9161b706.tar.xz |
(main): Make sure pw->pw_shell is non-NULL before trying to strdup it.
Patch from Dick Streefland.
-rw-r--r-- | src/su.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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)) |