Skip to content
This repository was archived by the owner on Sep 10, 2023. It is now read-only.

Commit c86f671

Browse files
committed
set_days_of_month: fix hang if day is 0
1 parent de539e9 commit c86f671

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ccronexpr.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,10 @@ static void set_days(char* field, uint8_t* targ, int max, const char** error) {
836836

837837
static void set_days_of_month(char* field, uint8_t* targ, const char** error) {
838838
/* Days of month start with 1 (in Cron and Calendar) so add one */
839-
set_days(field, targ, CRON_MAX_DAYS_OF_MONTH, error);
840-
/* ... and remove it from the front */
841-
if (targ) {
842-
cron_del_bit(targ, 0);
839+
if (1 == strlen(field) && '?' == field[0]) {
840+
field[0] = '*';
843841
}
844-
842+
set_number_hits(field, targ, 1, CRON_MAX_DAYS_OF_MONTH, error);
845843
}
846844

847845
void cron_parse_expr(const char* expression, cron_expr* target, const char** error) {

ccronexpr_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ void test_parse() {
335335
check_expr_invalid("/5 * * * * *");
336336
check_expr_invalid("*/0 * * * * *");
337337
check_expr_invalid("*/-0 * * * * *");
338+
check_expr_invalid("* 1 1 0 * *");
338339
}
339340

340341
void test_bits() {

0 commit comments

Comments
 (0)