]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Always pass NULL to time(2)
authorAlejandro Colomar <alx@kernel.org>
Tue, 14 May 2024 17:58:36 +0000 (19:58 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
See time(2):

BUGS
     Error returns from this system  call  are  indistinguishable  from
     successful  reports  that  the  time  is  a few seconds before the
     Epoch, so the C library wrapper function never sets errno as a re‐
     sult of this call.

     The tloc argument is obsolescent and should always be NULL in  new
     code.  When tloc is NULL, the call cannot fail.

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/failure.c
lib/log.c
lib/sulog.c
src/faillog.c
src/logoutd.c

index 55a10a71746c5bda5e8b0171030ba819ea06d83d..22acc231a00ba35b10aa79927329cec21cc8b00e 100644 (file)
@@ -82,7 +82,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
        }
 
        STRTCPY(fl->fail_line, tty);
-       (void) time (&fl->fail_time);
+       fl->fail_time = time(NULL);
 
        /*
         * Seek back to the correct position in the file and write the
@@ -126,7 +126,7 @@ static bool too_many_failures (const struct faillog *fl)
                return true;    /* locked until reset manually */
        }
 
-       (void) time (&now);
+       now = time(NULL);
        if ((fl->fail_time + fl->fail_locktime) < now) {
                return false;   /* enough time since last failure */
        }
index fd78c6823b07ece4e3980f67208a22eaa11ab48b..e195a0f943c14c44d2cf82f3016064dca686c10c 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -79,7 +79,7 @@ void dolastlog (
        }
 
        ll_time = newlog.ll_time;
-       (void) time (&ll_time);
+       ll_time = time(NULL);
        newlog.ll_time = ll_time;
        STRTCPY(newlog.ll_line, line);
 #if HAVE_LL_HOST
index 2ef22b2e16da7e77be4dc03ae5d4b3b135d740aa..82f3ab7722ffa1d4b8b48e1e5dfa378760381098 100644 (file)
@@ -68,7 +68,7 @@ void sulog (const char *tty, bool success, const char *oldname, const char *name
                return;         /* can't open or create logfile */
        }
 
-       (void) time (&now);
+       now = time(NULL);
        tm = localtime (&now);
 
        fprintf (fp, "SU %.02d/%.02d %.02d:%.02d %c %s %s-%s\n",
index 77c25b8ac38d502b059b4789cd3378d9b98264d4..75910bb6070d690c5205ce79191c92a38dbfff48 100644 (file)
@@ -154,7 +154,7 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
                return;
        }
 
-       (void) time(&now);
+       now = time(NULL);
 
        /* Filter out entries that do not match with the -t option */
        if (tflg && ((now - fl.fail_time) > seconds)) {
index eb4c6fe2088be94b5c7e03ca806f9371cb7ca18a..a0d0f36c17c5a1a5f70a394db3026d8f94a0d3f2 100644 (file)
@@ -55,7 +55,7 @@ check_login(const struct utmpx *ut)
        ZUSTR2STP(user, ut->ut_user);
        ZUSTR2STP(line, ut->ut_line);
 
-       (void) time (&now);
+       now = time(NULL);
 
        /*
         * Check if they are allowed to be logged in right now.