erofs-utils: lib: limit NONHEAD delta1 for compact indexes
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 21 Jan 2025 13:08:25 +0000 (21:08 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 21 Jan 2025 14:18:32 +0000 (22:18 +0800)
Otherwise it could be identified as a CBLKCNT lcluster.

It actually has no real impact for 4 KiB lclusters (blocks) since
EROFS_CONFIG_COMPR_MAX_SZ == 4 MiB and Z_EROFS_LI_D0_CBLKCNT means
2048 * 4KiB == 8 MiB.

Fixes: 0917ff150846 ("erofs-utils: fix delta[1] out-of-bound of compact indexes")
Fixes: 2f871035cca6 ("erofs-utils: mkfs: support compact indexes for bigpcluster")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250121130825.1722009-1-hsiangkao@linux.alibaba.com
lib/compress.c

index 20ab20847ca0b869881798a819f718f28ff3d63a..56b8c9b9e58fef741205a61518a6ae4e52f77360 100644 (file)
@@ -839,7 +839,7 @@ static void *write_compacted_indexes(u8 *out,
                                *dummy_head = false;
                        } else if (i + 1 == vcnt) {
                                offset = min_t(u16, cv[i].u.delta[1],
-                                               (1 << lobits) - 1);
+                                              Z_EROFS_LI_D0_CBLKCNT - 1);
                        } else {
                                offset = cv[i].u.delta[0];
                        }