Compressed cluster content includes compress cluster header, so calculation of dstlen parameter in LZ4_compress_fast_extState() should consider this design, otherwise compressed data may overflow destination buffer during compression.
Signed-off-by: Chao Yu <[email protected]> --- fsck/compress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsck/compress.c b/fsck/compress.c index 620768d..b413492 100644 --- a/fsck/compress.c +++ b/fsck/compress.c @@ -86,7 +86,8 @@ static int lz4_compress(struct compress_ctx *cc) { cc->clen = LZ4_compress_fast_extState(cc->private, cc->rbuf, (char *)cc->cbuf->cdata, cc->rlen, - cc->rlen - F2FS_BLKSIZE * c.compress.min_blocks, + cc->rlen - F2FS_BLKSIZE * c.compress.min_blocks - + COMPRESS_HEADER_SIZE, LZ4_ACCELERATION_DEFAULT); if (!cc->clen) -- 2.32.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
