diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2022-07-08 20:47:25 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2022-07-08 20:47:25 +0000 |
commit | bebaac5b8031ea182e973248426f9f9f20b1523f (patch) | |
tree | af8291d88122bfa78c22587dfb0c2e819a2da265 /usr.sbin/cron | |
parent | 1c47409c702d965373f525a9d584bcd3b0c59af6 (diff) |
Add a missing check for negative tv_sec when setting the timeout.
Also clear the entire timeout if the remaining time becomes negative
instead of just clearing tv_sec or tv_nsec. OK cheloha@.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r-- | usr.sbin/cron/cron.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index b00ffc6fb43..54b5574c292 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.81 2022/07/07 20:58:57 jca Exp $ */ +/* $OpenBSD: cron.c,v 1.82 2022/07/08 20:47:24 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -358,6 +358,8 @@ cron_sleep(time_t target, sigset_t *mask) clock_gettime(CLOCK_REALTIME, &t1); t1.tv_sec += GMToff; timeout.tv_sec = (target * SECONDS_PER_MINUTE - t1.tv_sec) + 1; + if (timeout.tv_sec < 0) + timeout.tv_sec = 0; timeout.tv_nsec = 0; pfd[0].fd = cronSock; @@ -417,9 +419,7 @@ cron_sleep(time_t target, sigset_t *mask) timespecsub(&timeout, &t1, &timeout); memcpy(&t1, &t2, sizeof(t1)); if (timeout.tv_sec < 0) - timeout.tv_sec = 0; - if (timeout.tv_nsec < 0) - timeout.tv_nsec = 0; + timespecclear(&timeout); } } |