block: qcow: Reject backing file size with zero offset

A qcow2 header with backing_file_offset == 0 indicates the image
has no backing file, so any non-zero backing_file_size is malformed.
Qemu silently ignores the size in this case, which hides image
corruption. Reject it explicitly with a dedicated error so the user
gets a clear diagnostic.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-06-01 16:25:32 +02:00
committed by Rob Bradford
parent 4294a4b862
commit 39e9376f5b
2 changed files with 7 additions and 0 deletions
+2
View File
@@ -74,6 +74,8 @@ pub enum Error {
BackingFileOutsideFirstCluster(u64, u32, u64),
#[error("Backing file name at offset {0:#x} length {1:#x} overlaps header of size {2:#x}")]
BackingFileOverlapsHeader(u64, u32, u32),
#[error("Backing file size {0:#x} with zero offset")]
BackingFileSizeWithoutOffset(u32),
#[error("Backing file support is disabled")]
BackingFilesDisabled,
#[error("Backing file name is too long: {0} bytes over")]