Skip to contentSkip to conversation

dump.f2fs: compress: fix dstlen of LZ4_compress_fast_extState()

PATCH New Chao Yu 1 participant 1 message Apr 26, 2022

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 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.

---
 fsck/compress.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fsck/compress.c +2 -1
index 620768d..b413492 100644
@@ -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)
Signature · 8 lines
2.32.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel