aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2025-02-05 12:49:18 +0000
committerKristof Provost <kp@FreeBSD.org>2025-02-12 08:29:09 +0000
commit21bc7eec2b7051025f100ce988bab79c2c172bc0 (patch)
tree4593a4504d7b49a2ab4403e3fe29572670eaf369 /sbin
parent0ce36b0698509e834ee406552035040b0a20856c (diff)
pfctl: avoid truncating a time_t division into days
Obtained from: OpenBSD, deraadt <deraadt@openbsd.org>, b14a9e0815 Sponsored by: Rubicon Communications, LLC ("Netgate")
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pfctl/pfctl_parser.c7
1 files 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);