[pve-devel] applied: [PATCH common] calendarevent: check range for start also without repetition

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Jun 2 09:33:01 CEST 2017


applied

On Thu, Jun 01, 2017 at 02:17:10PM +0200, Dominik Csapak wrote:
> 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 at proxmox.com>
> ---
>  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.11.0




More information about the pve-devel mailing list