From b0fd60a9de62a03189ad57d0c07f0ac51dc00e95 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Mon, 27 Feb 2023 17:28:59 +1100 Subject: [PATCH] Do shadow expiry calcs using "long long". Coverity flags these as potentially not 64bit time_t safe so use long long for the calculations and debug output. ok djm@ --- auth-shadow.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/auth-shadow.c b/auth-shadow.c index c77ee8da9..e1eb68bc3 100644 --- a/auth-shadow.c +++ b/auth-shadow.c @@ -56,13 +56,13 @@ int auth_shadow_acctexpired(struct spwd *spw) { time_t today; - int daysleft; + long long daysleft; int r; today = time(NULL) / DAY; daysleft = spw->sp_expire - today; - debug3("%s: today %d sp_expire %d days left %d", __func__, (int)today, - (int)spw->sp_expire, daysleft); + debug3("%s: today %lld sp_expire %lld days left %lld", __func__, + (long long)today, (long long)spw->sp_expire, daysleft); if (spw->sp_expire == -1) { debug3("account expiration disabled"); @@ -70,9 +70,9 @@ auth_shadow_acctexpired(struct spwd *spw) logit("Account %.100s has expired", spw->sp_namp); return 1; } else if (daysleft <= spw->sp_warn) { - debug3("account will expire in %d days", daysleft); + debug3("account will expire in %lld days", daysleft); if ((r = sshbuf_putf(loginmsg, - "Your account will expire in %d day%s.\n", daysleft, + "Your account will expire in %lld day%s.\n", daysleft, daysleft == 1 ? "" : "s")) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); }