[pve-devel] applied: [PATCH common] prevent autovivification of sectionconfig options

Thomas Lamprecht t.lamprecht at proxmox.com
Wed May 15 10:24:49 CEST 2019


On 5/15/19 10:03 AM, Dominik Csapak wrote:
> If, somehow, someone passes a config to check_config with keys set
> that are not in the options for that type, this fixed check
> lead to autovivification, meaning that any future calls to the same
> worker had an additional option for that type which is not optional
> 
> this lead to a wrongfully deleting of entries when updating an entry of
> a different type, since all entries of the original types suddenly
> did not satisfy their required options and would not get parsed
> by read_file anymore (thus missing when a successful write_file was done)
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PVE/SectionConfig.pm | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm
> index cc03aea..09ab5c2 100644
> --- a/src/PVE/SectionConfig.pm
> +++ b/src/PVE/SectionConfig.pm
> @@ -379,10 +379,10 @@ sub check_config {
>  
>      foreach my $k (keys %$config) {
>  	my $value = $config->{$k};
> -	
> +
>  	die "can't change value of fixed parameter '$k'\n"
> -	    if !$create && $opts->{$k}->{fixed};
> -	
> +	    if !$create && $opts->{$k} && $opts->{$k}->{fixed};
> +
>  	if (defined($value)) {
>  	    my $tmp = $class->check_value($type, $k, $value, $sectionId, $skipSchemaCheck);
>  	    $settings->{$k} = $class->decode_value($type, $k, $tmp);
> 

applied, with followup to use "defined" here, maybe fully correct could be
a ref(..) eq 'HASH', but we die on scalar as hash access anyway as we use
strict mode.

Thanks for finding this!




More information about the pve-devel mailing list