diff options
author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2023-03-05 03:58:08 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2023-03-05 04:07:19 +0800 |
commit | 0917ff15084600f2d4f4013267ef6fdb9834b13d (patch) | |
tree | 4d31409413262c9221bbf0c84c7b19b82caff2b2 | |
parent | 41790d24329de8f81b033eb77ce7cf9f70d403eb (diff) | |
download | erofs-utils-0917ff15084600f2d4f4013267ef6fdb9834b13d.tar.gz |
erofs-utils: fix delta[1] out-of-bound of compact indexes
delta[1] should not exceed (1 << lclusterbits) - 1, usually 4095
blocks, which means a single compressed extent which isn't less
than 16MiB could trigger this issue (it very rare happens).
Fixes: 76b822726ff8 ("erofs-utils: introduce compacted compression indexes")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230304195812.120063-1-hsiangkao@linux.alibaba.com
-rw-r--r-- | lib/compress.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/compress.c b/lib/compress.c index 65c6f90..f38c795 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -627,7 +627,8 @@ static void *write_compacted_indexes(u8 *out, blkaddr += cblks; *dummy_head = false; } else if (i + 1 == vcnt) { - offset = cv[i].u.delta[1]; + offset = min_t(u16, cv[i].u.delta[1], + (1 << logical_clusterbits) - 1); } else { offset = cv[i].u.delta[0]; } |