From: Gao Xiang <[email protected]>

Actually it's outdated code compared with kernel
commit b86269f43892 ("erofs: support parsing big pcluster compact indexes")

This will cause fsck.erofs works endlessly on some crafted images.

Reported-by: Chaoming Yang <[email protected]>
Fixes: 418fb683fd96 ("erofs-utils: fsck: fix an infinite loop of big pcluster")
Signed-off-by: Gao Xiang <[email protected]>
---
 lib/zmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/zmap.c b/lib/zmap.c
index 7b0fd83..6d9b033 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -322,7 +322,7 @@ static int unpack_compacted_index(struct 
z_erofs_maprecorder *m,
                                        nblk += lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
                                        continue;
                                }
-                               if (lo == 1) {
+                               if (lo <= 1) {
                                        DBG_BUGON(1);
                                        /* --i; ++nblk; continue; */
                                        return -EFSCORRUPTED;
-- 
2.30.2

Reply via email to