[pve-devel] [PATCH container] Fix: check if compression_map format is undefined

Alwin Antreich a.antreich at proxmox.com
Thu May 23 09:13:40 CEST 2019


We want to check for an supported compression type, but the check was
not correct as this only works if both sides are scalars, but an
assignment to an array is always "truthy", so actually check explicitly
if the compression type is supported before.

Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Create.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 8affe3f..e15d091 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -81,8 +81,8 @@ sub restore_archive {
 	);
 	if ($archive =~ /\.tar(\.[^.]+)?$/) {
 	    if (defined($1)) {
-		@compression_opt = $compression_map{$1}
-		    or die "unrecognized compression format: $1\n";
+		die "unrecognized compression format: $1\n" if (!defined($compression_map{$1}));
+		@compression_opt = $compression_map{$1};
 	    }
 	} else {
 	    die "file does not look like a template archive: $archive\n";
-- 
2.11.0





More information about the pve-devel mailing list