jcs's openbsd hax
openbsd

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@.

millert 9c847fa8 055943a1

+4 -4
+4 -4
usr.sbin/cron/cron.c
··· 1 - /* $OpenBSD: cron.c,v 1.81 2022/07/07 20:58:57 jca Exp $ */ 1 + /* $OpenBSD: cron.c,v 1.82 2022/07/08 20:47:24 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 358 358 clock_gettime(CLOCK_REALTIME, &t1); 359 359 t1.tv_sec += GMToff; 360 360 timeout.tv_sec = (target * SECONDS_PER_MINUTE - t1.tv_sec) + 1; 361 + if (timeout.tv_sec < 0) 362 + timeout.tv_sec = 0; 361 363 timeout.tv_nsec = 0; 362 364 363 365 pfd[0].fd = cronSock; ··· 417 419 timespecsub(&timeout, &t1, &timeout); 418 420 memcpy(&t1, &t2, sizeof(t1)); 419 421 if (timeout.tv_sec < 0) 420 - timeout.tv_sec = 0; 421 - if (timeout.tv_nsec < 0) 422 - timeout.tv_nsec = 0; 422 + timespecclear(&timeout); 423 423 } 424 424 } 425 425