aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2022-04-26 23:26:46 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2022-04-26 16:05:35 -0700
commit0b9b89fda2e9fbaf17a11fa15332e7ae95cf5261 (patch)
tree4bd617abed18ce1a1ed315147559a7aeddca8275
parenteee3969d7dcf3be9c3b831d993fcf49f55855a35 (diff)
downloadf2fs-tools-0b9b89fda2e9fbaf17a11fa15332e7ae95cf5261.tar.gz
dump.f2fs: compress: fix dstlen of LZ4_compress_fast_extState()
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 <chao.yu@oppo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fsck/compress.c3
1 files changed, 2 insertions, 1 deletions
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)