Skip to content

Commit 89c850a

Browse files
committedJan 14, 2025·
fix(cron): fix the range limits for minutes, hours, and weeks
Minutes: 0 to 59 Hours: 0 to 23 Weeks: 0 to 7, where both 0 and 7 represent Sunday
1 parent 6af2d2c commit 89c850a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎src/mln_cron.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ MLN_FUNC(static, long, mln_cron_parse_minute, (mln_string_t *smin, long min), (s
8585
if (p == head || p > head + 2) return -1;
8686
*p = 0;
8787
tmp = atol((char *)head);
88-
if (tmp < 1 || tmp >= 60) {
89-
return -1;
90-
}
88+
if (tmp < 1 || tmp >= 60) return -1;
9189
if (tmp < min) tmp += 60;
9290
if (!save) {
9391
save = min == tmp? min + period: tmp;
@@ -110,7 +108,7 @@ MLN_FUNC(static, long, mln_cron_parse_minute, (mln_string_t *smin, long min), (s
110108
if (p > head) {
111109
if (p > head + 2) return -1;
112110
tmp = atol((char *)head);
113-
if (tmp < 1 || tmp >= 60) return -1;
111+
if (tmp < 0 || tmp >= 60) return -1;
114112
if (tmp < min) tmp += 60;
115113
if (!save) {
116114
save = min == tmp? min + period: tmp;
@@ -178,7 +176,7 @@ MLN_FUNC(static, long, mln_cron_parse_hour, \
178176
if (p > head) {
179177
if (p > head + 2) return -1;
180178
tmp = atol((char *)head);
181-
if (tmp < 1 || tmp >= 24) return -1;
179+
if (tmp < 0 || tmp >= 24) return -1;
182180
if (tmp < hour) tmp += 24;
183181
if (!save) {
184182
save = hour==tmp && !greater? hour + period: tmp;
@@ -394,6 +392,7 @@ MLN_FUNC(static, long, mln_cron_parse_week, \
394392
if (p > head) {
395393
if (p > head + 1) return -1;
396394
tmp = atol((char *)head);
395+
if (tmp == 7) tmp = 0;
397396
if (tmp < 0 || tmp >= 7) return -1;
398397
if (tmp < week) tmp += 7;
399398
if (!save) {

0 commit comments

Comments
 (0)
Please sign in to comment.