Skip to content

Commit

Permalink
rafs: fix a bug in calculate offset for dirent name
Browse files Browse the repository at this point in the history
There's a bug in calculate offset and size for RAFS v6 Dirent name,
it will be treat as 0 instead of 4096 if the last block is 4096 bytes.

Fixes: #1098

Signed-off-by: Jiang Liu <[email protected]>
  • Loading branch information
jiangliu committed Feb 24, 2023
1 parent 6189871 commit 2616fb2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,13 @@ impl OndiskInodeWrapper {
let block_count = self.blocks_count() as usize;
let len = match block_count.cmp(&(block_index + 1)) {
Ordering::Greater => (EROFS_BLOCK_SIZE - base) as usize,
Ordering::Equal => (self.size() % EROFS_BLOCK_SIZE - base) as usize,
Ordering::Equal => {
if self.size() % EROFS_BLOCK_SIZE == 0 {
EROFS_BLOCK_SIZE as usize
} else {
(self.size() % EROFS_BLOCK_SIZE - base) as usize
}
}
Ordering::Less => return Err(RafsError::InvalidImageData),
};

Expand Down

0 comments on commit 2616fb2

Please sign in to comment.