From 057c619ab2591416e452d1b65734229bb8926d5f Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 1 Jun 2017 14:17:10 +0200 Subject: [PATCH 1/1] calendarevent: check range for start also without repetition else an event like "61" never finishes when calculating the next event also add regression tests for this and other range checks Signed-off-by: Dominik Csapak --- src/PVE/CalendarEvent.pm | 1 + test/calendar_event_test.pl | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/PVE/CalendarEvent.pm b/src/PVE/CalendarEvent.pm index 2714841..a053f38 100644 --- a/src/PVE/CalendarEvent.pm +++ b/src/PVE/CalendarEvent.pm @@ -55,6 +55,7 @@ sub parse_calendar_event { $$matchall_ref = 1; } else { $start = int($start); + die "value '$start' out of range\n" if $start >= $max; $res_hash->{$start} = 1; } } diff --git a/test/calendar_event_test.pl b/test/calendar_event_test.pl index ec8fcc0..9c2bf46 100755 --- a/test/calendar_event_test.pl +++ b/test/calendar_event_test.pl @@ -132,7 +132,19 @@ my $tests = [ [20*60*60, 20*60*60 + 30*60], [22*60*60 + 30*60, 44*60*60] ] - ] + ], + [ + '61', + { error => "value '61' out of range" }, + ], + [ + '*/61', + { error => "repetition '61' out of range" }, + ], + [ + '0..80', + { error => "range end '80' out of range" }, + ], ]; foreach my $test (@$tests) { -- 2.39.2