Skip to content

Commit 2616fb2

Browse files
committed
rafs: fix a bug in calculate offset for dirent name
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]>
1 parent 6189871 commit 2616fb2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

rafs/src/metadata/direct_v6.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,13 @@ impl OndiskInodeWrapper {
408408
let block_count = self.blocks_count() as usize;
409409
let len = match block_count.cmp(&(block_index + 1)) {
410410
Ordering::Greater => (EROFS_BLOCK_SIZE - base) as usize,
411-
Ordering::Equal => (self.size() % EROFS_BLOCK_SIZE - base) as usize,
411+
Ordering::Equal => {
412+
if self.size() % EROFS_BLOCK_SIZE == 0 {
413+
EROFS_BLOCK_SIZE as usize
414+
} else {
415+
(self.size() % EROFS_BLOCK_SIZE - base) as usize
416+
}
417+
}
412418
Ordering::Less => return Err(RafsError::InvalidImageData),
413419
};
414420

0 commit comments

Comments
 (0)