From 40d2427fd7f788262dc3bf220f789b7bd5fe781b Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 4 Jan 2019 04:06:54 +0100 Subject: fusefrontend: Fix computation of cipherSz in Allocate FUSE call. Do not use PlainSizeToCipherSize() since this adds the 18 bytes file header. Partially fixes https://github.com/rfjakob/gocryptfs/issues/311 --- internal/fusefrontend/file_allocate_truncate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/fusefrontend/file_allocate_truncate.go b/internal/fusefrontend/file_allocate_truncate.go index b64e19b..b75462d 100644 --- a/internal/fusefrontend/file_allocate_truncate.go +++ b/internal/fusefrontend/file_allocate_truncate.go @@ -62,7 +62,7 @@ func (f *File) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { // the file. cipherOff := firstBlock.BlockCipherOff() cipherSz := lastBlock.BlockCipherOff() - cipherOff + - f.contentEnc.PlainSizeToCipherSize(lastBlock.Skip+lastBlock.Length) + f.contentEnc.BlockOverhead() + lastBlock.Skip + lastBlock.Length err := syscallcompat.Fallocate(f.intFd(), FALLOC_FL_KEEP_SIZE, int64(cipherOff), int64(cipherSz)) tlog.Debug.Printf("Allocate off=%d sz=%d mode=%x cipherOff=%d cipherSz=%d\n", off, sz, mode, cipherOff, cipherSz) -- cgit v1.2.3