From 362a9ecc4feb2be13484c1b4dd52b342dce53132 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 1 Jun 2026 17:35:16 +0200 Subject: [PATCH] block: qcow: Test rejection of backing file offset with zero size Cover the malformed header case where backing_file_offset is non zero but backing_file_size is zero, which must be rejected with the new dedicated error. Signed-off-by: Anatol Belski --- block/src/formats/qcow/internal/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/src/formats/qcow/internal/mod.rs b/block/src/formats/qcow/internal/mod.rs index 68a0b63b1..86c51028d 100644 --- a/block/src/formats/qcow/internal/mod.rs +++ b/block/src/formats/qcow/internal/mod.rs @@ -2759,6 +2759,12 @@ mod unit_tests { assert!(matches!(err, Error::BackingFileSizeWithoutOffset(16))); } + #[test] + fn backing_file_offset_without_size() { + let err = read_header_with_patched_backing(1024, 0).unwrap_err(); + assert!(matches!(err, Error::BackingFileOffsetWithoutSize(1024))); + } + #[test] fn backing_file_fits_at_cluster_end() { let cluster_size = 1u64 << DEFAULT_CLUSTER_BITS;