]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Initialize local variables
authorIker Pedrosa <ipedrosa@redhat.com>
Mon, 16 May 2022 15:24:58 +0000 (17:24 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 24 May 2022 12:49:11 +0000 (07:49 -0500)
CWE-457 by CodeQL.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
lib/run_part.c
src/faillog.c
src/lastlog.c

index 1e4f154b3c475880ab292f12209942ac88c57609..bce11d37a45a58cc3ffc7e65c8124c495b040419 100644 (file)
@@ -45,7 +45,7 @@ int run_parts (const char *directory, const char *name, const char *action)
        struct dirent **namelist;
        int scanlist;
        int n;
-       int execute_result;
+       int execute_result = 0;
 
        scanlist = scandir (directory, &namelist, 0, alphasort);
        if (scanlist<=0) {
index d33fe9b6324ecc393b4b8861f0d0aa49b1ac29f7..0f94836f7b2f86768cacbf4a31122ba8a545b0bd 100644 (file)
@@ -537,9 +537,9 @@ static void set_locktime (long locktime)
 
 int main (int argc, char **argv)
 {
-       long fail_locktime;
+       long fail_locktime = 0;
        short fail_max = 0; // initialize to silence compiler warning
-       long days;
+       long days = 0;
 
        /*
         * Get the program name. The program name is used as a prefix to
index 3c0fc9c6276843fb55e79c95906279a34aef8c9d..0d4b5fd228d7ffd17858e931f40cdf2447127432 100644 (file)
@@ -88,7 +88,16 @@ static void print_one (/*@null@*/const struct passwd *pw)
        char ptime[80];
 
 #ifdef HAVE_LL_HOST
-       int maxIPv6Addrlen;
+       /*
+        * ll_host is in minimized form, thus the maximum IPv6 address possible is
+        * 8*4+7 = 39 characters.
+        * RFC 4291 2.5.6 states that for LL-addresses fe80+only the interface ID is set,
+        * thus having a maximum size of 25+1+IFNAMSIZ.
+        * POSIX says IFNAMSIZ should be 16 characters long including the null byte, thus
+        * 25+1+IFNAMSIZ >= 42 > 39
+        */
+       /* Link-Local address + % + Interfacename */
+       const int maxIPv6Addrlen = 25+1+IFNAMSIZ;
 #endif
 
        if (NULL == pw) {
@@ -132,16 +141,6 @@ static void print_one (/*@null@*/const struct passwd *pw)
        /* Print the header only once */
        if (!once) {
 #ifdef HAVE_LL_HOST
-               /*
-                * ll_host is in minimized form, thus the maximum IPv6 address possible is
-                * 8*4+7 = 39 characters.
-                * RFC 4291 2.5.6 states that for LL-addresses fe80+only the interface ID is set,
-                * thus having a maximum size of 25+1+IFNAMSIZ.
-                * POSIX says IFNAMSIZ should be 16 characters long including the null byte, thus
-                * 25+1+IFNAMSIZ >= 42 > 39
-                */
-               /* Link-Local address + % + Interfacename */
-               maxIPv6Addrlen = 25+1+IFNAMSIZ;
                printf (_("Username         Port     From%*sLatest\n"), maxIPv6Addrlen-3, " ");
 #else
                puts (_("Username                Port     Latest"));