git: 21bc7eec2b70 - main - pfctl: avoid truncating a time_t division into days

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Wed, 12 Feb 2025 09:38:45 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=21bc7eec2b7051025f100ce988bab79c2c172bc0

commit 21bc7eec2b7051025f100ce988bab79c2c172bc0
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-02-05 12:49:18 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-02-12 08:29:09 +0000

    pfctl: avoid truncating a time_t division into days
    
    Obtained from:  OpenBSD, deraadt <deraadt@openbsd.org>, b14a9e0815
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/pfctl_parser.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 7a1339ad273a..f567cc78dd23 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -513,7 +513,8 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts)
 	running = s->running ? "Enabled" : "Disabled";
 
 	if (s->since) {
-		unsigned int	sec, min, hrs, day = runtime;
+		unsigned int	sec, min, hrs;
+		time_t		day = runtime;
 
 		sec = day % 60;
 		day /= 60;
@@ -522,8 +523,8 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts)
 		hrs = day % 24;
 		day /= 24;
 		snprintf(statline, sizeof(statline),
-		    "Status: %s for %u days %.2u:%.2u:%.2u",
-		    running, day, hrs, min, sec);
+		    "Status: %s for %lld days %.2u:%.2u:%.2u",
+		    running, (long long)day, hrs, min, sec);
 	} else
 		snprintf(statline, sizeof(statline), "Status: %s", running);
 	printf("%-44s", statline);