From: Thomas Lamprecht Date: Fri, 5 Jul 2019 16:48:33 +0000 (+0200) Subject: followup: code cleanup and uninitialized value access fix X-Git-Url: https://git.proxmox.com/?p=pve-container.git;a=commitdiff_plain;h=e80cb0cd1e99faf0458427280ba3ebd5784ead88 followup: code cleanup and uninitialized value access fix Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 13ead7f..2252685 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1415,11 +1415,11 @@ sub mountpoint_mount { die "unknown snapshot path for '$volid'" if !$storage && defined($snapname); - my @mountoptions= split(/;/, $mountpoint->{mountoptions}); my $optlist = []; - my $allowed_options = PVE::LXC::Config::get_mount_options(); - foreach my $opt (@mountoptions) { - push @$optlist, $opt if $opt =~ $allowed_options + + if (my $mountopts = $mountpoint->{mountoptions}) { + my @opts = split(/;/, $mountpoint->{mountoptions}); + push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts; } my $acl = $mountpoint->{acl}; diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 71788ba..49f2345 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -216,10 +216,12 @@ sub __snapshot_foreach_volume { cfs_register_file('/lxc/', \&parse_pct_config, \&write_pct_config); -my $mount_option = qr/(noatime|nodev|nosuid|noexec)/; -sub get_mount_options { - return $mount_option; +my $valid_mount_option_re = qr/(noatime|nodev|nosuid|noexec)/; + +sub is_valid_mount_option { + my ($option) = @_; + return $option =~ $valid_mount_option_re; } my $rootfs_desc = { @@ -247,7 +249,7 @@ my $rootfs_desc = { type => 'string', description => 'Extra mount options for rootfs/mps.', format_description => 'opt[;opt...]', - pattern => qr/$mount_option(;$mount_option)*/, + pattern => qr/$valid_mount_option_re(;$valid_mount_option_re)*/, }, ro => { type => 'boolean',