[pve-devel] [PATCH container v2] Create: fix architecture detection in restore_archive

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Dec 20 06:36:13 CET 2016


On 12/19/2016 08:40 AM, Wolfgang Bumiller wrote:
> [snip]
>
> +	    my $length = read($fh, $data, 5);
> +	    die "read failed: $!\n" if !defined($length);
> +
> +	    # 4 bytes ELF magic number and 1 byte ELF class
> +	    my ($magic, $class) = unpack("A4C", $data);
> +
> +	    die "'$binary_fn' does not resolve to an ELF!\n"
> +		if ((!defined($magic) || !defined($class)) && $magic ne "\177ELF");
> Why is this (||)&& construct there? If $magic is undef the left side of
> the && will be true and thus the right side executed, comparing undef to
> "\177ELF", producing a warning.
>
>   => if (!defined($magic) || !defined($class) || $magic ne "\177ELF")
>

Ugh, you're right! Added this mistakenly on refactoring :/
Thanks for your review, I'll send a v3.





More information about the pve-devel mailing list