From: Dominik Csapak Date: Thu, 1 Jun 2017 12:17:10 +0000 (+0200) Subject: calendarevent: check range for start also without repetition X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=057c619ab2591416e452d1b65734229bb8926d5f;hp=d31335c674a63f4f41a88ea4ddbdfb08385a9831 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 --- 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) {