From 3414ff74ba6694793251fca781b4da2469635fe5 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 30 Jun 2014 20:29:43 +0200 Subject: [PATCH] cron: Fixes (correct month / day bitmaps and the days_in_month check) --- src/cron.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cron.c b/src/cron.c index 325ff6d1..6e9de261 100644 --- a/src/cron.c +++ b/src/cron.c @@ -57,8 +57,8 @@ cron_parse_field uint64_t val = 0; while ( 1 ) { if ( *str == '*' ) { - sn = 0; - en = bits - 1; + sn = off; + en = bits + off - 1; beg = NULL; } else if ( *str == ',' || *str == ' ' || *str == '\0' ) { if (beg) @@ -70,7 +70,7 @@ cron_parse_field if (mn < 0) mn = 1; while (sn <= en) { if ( (sn % mn) == 0 ) - val |= (0x1LL << (sn - off)); + val |= (0x1ULL << (sn - off)); sn++; } if (*str != ',') break; @@ -227,7 +227,7 @@ cron_next ( cron_t *c, const time_t now, time_t *ret ) /* Date */ if (nxt.tm_wday == 7) nxt.tm_wday = 0; - if (nxt.tm_mday == days_in_month(nxt.tm_year+1900, nxt.tm_mon+1)) { + if (nxt.tm_mday > days_in_month(nxt.tm_year+1900, nxt.tm_mon+1)) { nxt.tm_mday = 1; nxt.tm_mon++; if (nxt.tm_mon == 12) {