Skip to content

Commit

Permalink
src/login.c: Use localtime_r(3) instead of localtime(3)
Browse files Browse the repository at this point in the history
This silences a CodeQL warning.  We don't care about reentrancy, but
after this patch we don't need to break a long line, so that's a win.

Reviewed-by: "Serge E. Hallyn" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Mar 23, 2024
1 parent 0460dac commit 4827da0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/login.c
Expand Up @@ -1253,10 +1253,11 @@ int main (int argc, char **argv)
&& pwd->pw_uid <= (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL)
&& (ll.ll_time != 0))
{
time_t ll_time = ll.ll_time;
time_t ll_time = ll.ll_time;
struct tm tm;

STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y",
localtime(&ll_time));
localtime_r(&ll_time, &tm);
STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y", &tm);
printf (_("Last login: %s on %s"),
ptime, ll.ll_line);
#ifdef HAVE_LL_HOST /* __linux__ || SUN4 */
Expand Down

0 comments on commit 4827da0

Please sign in to comment.