[thin/cache (rust)] Validate superblock checksum
This commit is contained in:
parent
8a822cebec
commit
71d47ef58b
6
src/cache/superblock.rs
vendored
6
src/cache/superblock.rs
vendored
@ -134,7 +134,11 @@ fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
||||
pub fn read_superblock(engine: &dyn IoEngine, loc: u64) -> Result<Superblock> {
|
||||
let b = engine.read(loc)?;
|
||||
|
||||
if let Ok((_, sb)) = unpack(&b.get_data()) {
|
||||
if metadata_block_type(b.get_data()) != BT::CACHE_SUPERBLOCK {
|
||||
return Err(anyhow!("bad checksum in superblock"));
|
||||
}
|
||||
|
||||
if let Ok((_, sb)) = unpack(b.get_data()) {
|
||||
Ok(sb)
|
||||
} else {
|
||||
Err(anyhow!("couldn't unpack superblock"))
|
||||
|
@ -89,7 +89,11 @@ fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
||||
pub fn read_superblock(engine: &dyn IoEngine, loc: u64) -> Result<Superblock> {
|
||||
let b = engine.read(loc)?;
|
||||
|
||||
if let Ok((_, sb)) = unpack(&b.get_data()) {
|
||||
if metadata_block_type(b.get_data()) != BT::THIN_SUPERBLOCK {
|
||||
return Err(anyhow!("bad checksum in superblock"));
|
||||
}
|
||||
|
||||
if let Ok((_, sb)) = unpack(b.get_data()) {
|
||||
Ok(sb)
|
||||
} else {
|
||||
Err(anyhow!("couldn't unpack superblock"))
|
||||
|
Loading…
Reference in New Issue
Block a user