[PATCH 4/4] erofs-utils: lib: fix `INTEGER_OVERFLOW`
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Jul 8 12:17:22 AEST 2025
Coverity-id: 569453
Fixes: 341d23a878a2 ("erofs-utils: mkfs: speed up uncompressed data handling")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/compress.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/lib/compress.c b/lib/compress.c
index 8999b2c7..bf471218 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -579,18 +579,15 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
if (len <= ctx->pclustersize) {
if (!final || !len)
return 1;
- if (may_packing) {
- if (inode->fragment_size && !ictx->fix_dedupedfrag) {
- ctx->pclustersize = roundup(len, blksz);
- goto fix_dedupedfrag;
- }
- e->length = len;
- goto frag_packing;
+ if (may_packing && inode->fragment_size && !ictx->fix_dedupedfrag) {
+ ctx->pclustersize = roundup(len, blksz);
+ goto fix_dedupedfrag;
}
- if (!may_inline && len <= blksz) {
- e->length = len;
+ e->length = len;
+ if (may_packing)
+ goto frag_packing;
+ if (!may_inline && len <= blksz)
goto nocompression;
- }
}
e->length = min(len, cfg.c_max_decompressed_extent_bytes);
@@ -629,7 +626,7 @@ retry_aligned:
} else {
may_inline = false;
may_packing = false;
- e->length = min_t(u32, e->length, ret);
+ e->length = min_t(u32, e->length, ctx->pclustersize);
nocompression:
if (cfg.c_dedupe)
ret = write_uncompressed_block(ctx, len, dst);
--
2.43.5
More information about the Linux-erofs
mailing list