[pve-devel] [PATCH storage] file_size_info: check format for untrusted files
Dominik Csapak
d.csapak at proxmox.com
Wed Nov 20 10:19:41 CET 2024
so we fail early for files disguising as a different format (e.g. vhdx).
One can't use such files anyway since we explicitly add the expected
format to disks, so this only gives an earlier and prettier error when
e.g. importing an OVA file with such a badly named disk image.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/Storage/Plugin.pm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 0b0b5a8..6a7f468 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1035,6 +1035,12 @@ sub file_size_info {
$used = int($used);
($format) = ($format =~ /^(\S+)$/); # untaint
die "format '$format' includes whitespace\n" if !defined($format);
+
+ if ($untrusted) {
+ die "format '$format' not supported\n"
+ if $format ne 'raw' && $format ne 'qcow2' && $format ne 'vmdk';
+ }
+
if (defined($parent)) {
warn "strange parent name path '$parent' found\n" if $parent =~ m/[^\S]/;
($parent) = ($parent =~ /^(\S+)$/); # untaint
--
2.39.5
More information about the pve-devel
mailing list