]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
(main): Make sure pw->pw_shell is non-NULL before trying to strdup it.
authorJim Meyering <jim@meyering.net>
Wed, 10 Dec 1997 10:25:46 +0000 (10:25 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 10 Dec 1997 10:25:46 +0000 (10:25 +0000)
Patch from Dick Streefland.

login-utils/su.c

index 108d06239d32caa700ade42a59639edfdbd6b262..dda02fe09a101d56c94ab372ae5363b066e96c27 100644 (file)
@@ -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))