[pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum

Oguz Bektas o.bektas at proxmox.com
Thu Dec 2 14:38:42 CET 2021


so that we don't get checksum mismatch in case the user accidentally
copies whitespace in the checksum field.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 src/PVE/Tools.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 787942a..fa14f2f 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -1921,6 +1921,7 @@ sub download_file_from_url {
 	if (defined($opts->{"${_}sum"})) {
 	    $checksum_algorithm = $_;
 	    $checksum_expected = $opts->{"${_}sum"};
+	    $checksum_expected =~ s/^\s+|\s+$//g;
 	    last;
 	}
     }
-- 
2.30.2






More information about the pve-devel mailing list