Skip to contentSkip to conversation

erofs-utils: lib: return -EFSCORRUPTED for oversized tail pclusters

PATCH New Zhan Xusheng 1 participant 1 message Nov 21 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: return -EFSCORRUPTED for oversized tail pclusters

From: Zhan Xusheng <[email protected]>

z_erofs_map_blocks_fo() prints "invalid tail-packing pclustersize" when a tail-packed pcluster crosses a block boundary, but err is still 0 there, so the mapping succeeds. With h_idata_size of a file in an -Eztailpacking image set to 4080, fsck.erofs prints the message and exits with 0.

Return -EFSCORRUPTED, as the check did before it was moved here.

Fixes 97ad172b79b7 ("erofs-utils: lib: clean up header parsing for ztailpacking and fragments")
---
 lib/zmap.c | 1 +
 1 file changed, 1 insertion(+)
lib/zmap.c +1 -0
index 5b44b60..40a376b 100644
@@ -501,6 +501,7 @@ static int z_erofs_map_blocks_fo(struct erofs_inode *vi,
 		if (erofs_blkoff(sbi, map->m_pa) + map->m_plen > erofs_blksiz(sbi)) {
 			erofs_err("invalid tail-packing pclustersize %llu",
 				  map->m_plen | 0ULL);
+			err = -EFSCORRUPTED;
 			goto out;
 		}
 	} else if (fragment && m.lcn == vi->z_tailextent_headlcn) {

base-commit: 8a8d4892b6b09919053ba3561d289af76095c625

Signature · 1 line
2.43.0