mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Reject backing file offset with zero size
A qcow2 header with non-zero backing_file_offset that points at a zero length name is malformed. The parser would otherwise read an empty path string and store it as a backing file. Reject it 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:
committed by
Rob Bradford
parent
39e9376f5b
commit
53a9ae08c2
@@ -336,6 +336,11 @@ impl QcowHeader {
|
||||
header.backing_file_size,
|
||||
));
|
||||
}
|
||||
if header.backing_file_offset != 0 && header.backing_file_size == 0 {
|
||||
return Err(Error::BackingFileOffsetWithoutSize(
|
||||
header.backing_file_offset,
|
||||
));
|
||||
}
|
||||
if header.backing_file_offset != 0 {
|
||||
let cluster_size = 1u64
|
||||
.checked_shl(header.cluster_bits)
|
||||
|
||||
@@ -66,6 +66,8 @@ use crate::error::{BlockError, BlockErrorKind, BlockResult};
|
||||
pub enum Error {
|
||||
#[error("Backing file I/O error: {0}")]
|
||||
BackingFileIo(String /* path */, #[source] io::Error),
|
||||
#[error("Backing file offset {0:#x} with zero size")]
|
||||
BackingFileOffsetWithoutSize(u64),
|
||||
#[error("Backing file open error: {0}")]
|
||||
BackingFileOpen(String /* path */, #[source] Box<Error>),
|
||||
#[error(
|
||||
|
||||
Reference in New Issue
Block a user