nbari / cron-parser

cron parser

Home Page:https://docs.rs/cron-parser/latest/cron_parser/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Program panicked when number of fields less than 5

LemonNekoGH opened this issue · comments

I got error when i parse wrong cron expression: * * * *

index out of bounds: the len is 4 but the index is 4

And i found this line try to get field by index 4:

let do_w = parse_field(fields[4], 0, 6)?;

Then i found these line checked if number of fields greater than 5, will throw a error:

cron-parser/src/lib.rs

Lines 123 to 125 in 37500d2

if fields.len() > 5 {
return Err(ParseError::InvalidCron);
}

Should we throw a error if number of fields less than 4? Like this:

if fields.len() != 5 {
    return Err(ParseError::InvalidCron);
}

Hi @LemonNekoGH, many thanks, fixed 👍