tools/systemd/parse_time: error out on invalid ranges

if the range is reverse (bigger..smaller) we will never find a value,
so error out during parsing

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-09-04 14:33:29 +02:00 committed by Dietmar Maurer
parent 07ca6f6e66
commit ce7ab28cfa
1 changed files with 3 additions and 0 deletions

View File

@ -145,6 +145,9 @@ fn parse_date_time_comp(max: usize) -> impl Fn(&str) -> IResult<&str, DateTimeVa
let (i, value) = parse_time_comp(max)(i)?;
if let (i, Some(end)) = opt(preceded(tag(".."), parse_time_comp(max)))(i)? {
if value > end {
return Err(parse_error(i, "range start is bigger than end"));
}
return Ok((i, DateTimeValue::Range(value, end)))
}