[hackers] [ubase] su: set default 'root', fixes a uninitialised variable warning || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Fri, 14 Feb 2014 15:11:33 +0100

commit 96af28da605a7c6a9f30f047af3686d1a9e09aad
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Feb 14 14:49:34 2014 +0100

    su: set default 'root', fixes a uninitialised variable warning
    
    Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>

diff --git a/su.c b/su.c
index 2cbc57e..aa7f8af 100644
--- a/su.c
+++ b/su.c
_AT_@ -28,7 +28,7 @@ static int pflag = 0;
 int
 main(int argc, char **argv)
 {
- char *usr, *pass, *cryptpass;
+ char *usr = "root", *pass, *cryptpass;
         char * const *newargv;
         struct spwd *spw;
         struct passwd *pw;
_AT_@ -47,14 +47,12 @@ main(int argc, char **argv)
         } ARGEND;
 
         if (argc < 1)
- usr = "root";
+ ;
         else if (argc == 1)
                 usr = argv[0];
         else
                 usage();
 
- uid = getuid();
-
         errno = 0;
         spw = getspnam(usr);
         if (errno)
_AT_@ -72,6 +70,7 @@ main(int argc, char **argv)
                 enprintf(EXIT_FAILURE, "Invalid shadow record
");
         }
 
+ uid = getuid();
         if (uid) {
                 pass = getpass("Password: ");
                 if (!pass)
Received on Fri Feb 14 2014 - 15:11:33 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 14 2014 - 15:12:33 CET