summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-01-29 23:35:43 +0100
committerAlejandro Colomar <alx@kernel.org>2024-03-24 00:16:00 +0100
commit4827da0a2f67214792aed72f445b5a53ffcb87df (patch)
treee5eeb9d6f57dfed9cb86719e01ba420a08efa12a
parent0460dac019c5b28471aed1f184ce470797dd26a6 (diff)
src/login.c: Use localtime_r(3) instead of localtime(3)
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" <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--src/login.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/login.c b/src/login.c
index 16236de3..a862c6bd 100644
--- a/src/login.c
+++ b/src/login.c
@@ -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 */