From 842515699a0ef45d84d0a9e56d949d7a32cb0723 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Thu, 19 Mar 2026 10:40:26 +0200 Subject: [PATCH] squashfs: properly handle filecopy and blocksize Signed-off-by: Avi Deitcher --- filesystem/squashfs/finalize.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/filesystem/squashfs/finalize.go b/filesystem/squashfs/finalize.go index d5b2dec..4f1b6a4 100644 --- a/filesystem/squashfs/finalize.go +++ b/filesystem/squashfs/finalize.go @@ -380,6 +380,7 @@ func copyFileData(from backend.File, to backend.WritableFile, fromOffset, toOffs // compress the block if needed isCompressed := false + outBuf := buf[:n] if c != nil { out, err := c.compress(buf) if err != nil { @@ -387,15 +388,14 @@ func copyFileData(from backend.File, to backend.WritableFile, fromOffset, toOffs } if len(out) < len(buf) { isCompressed = true - buf = out - n = len(out) + outBuf = out } } - blocks = append(blocks, &blockData{size: uint32(len(buf)), compressed: isCompressed}) - if _, err := to.WriteAt(buf[:n], toOffset+int64(compressed)); err != nil { + blocks = append(blocks, &blockData{size: uint32(len(outBuf)), compressed: isCompressed}) + if _, err := to.WriteAt(outBuf, toOffset+int64(compressed)); err != nil { return raw, compressed, blocks, err } - compressed += len(buf) + compressed += len(outBuf) } return raw, compressed, blocks, nil }