block: qcow: Test rejection of backing file size with zero offset

Cover the malformed header case where backing_file_offset is zero
but backing_file_size is non zero, which must be rejected with the
new dedicated error.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-06-01 16:26:30 +02:00
committed by Rob Bradford
parent 05cac5657c
commit 679892f56e

View File

@@ -2753,6 +2753,12 @@ mod unit_tests {
assert!(matches!(err, Error::BackingFileOverlapsHeader(_, _, _)));
}
#[test]
fn backing_file_size_without_offset() {
let err = read_header_with_patched_backing(0, 16).unwrap_err();
assert!(matches!(err, Error::BackingFileSizeWithoutOffset(16)));
}
#[test]
fn backing_file_fits_at_cluster_end() {
let cluster_size = 1u64 << DEFAULT_CLUSTER_BITS;