]> git.proxmox.com Git - pve-common.git/commitdiff
calendarevent: check range for start also without repetition
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 1 Jun 2017 12:17:10 +0000 (14:17 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 2 Jun 2017 07:30:55 +0000 (09:30 +0200)
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 <d.csapak@proxmox.com>
src/PVE/CalendarEvent.pm
test/calendar_event_test.pl

index 2714841c1aab6039c4f6337e348d61d68231734d..a053f389d5c3b1ed7cdf862174e362a7dfde116f 100644 (file)
@@ -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;
                }
            }
index ec8fcc0c84db97a50a583fa3b1dcfd29a4854c3b..9c2bf46075acc316553e57c50773129e19a3880c 100755 (executable)
@@ -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) {