From 3009ec9852316c3c696f77f476390ab5a6d8d6d7 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 17 Oct 2017 21:47:32 +0200 Subject: fusefrontend: clamp oversized reads Our byte cache pools are sized acc. to MAX_KERNEL_WRITE, but the running kernel may have a higher limit set. Clamp to what we can handle. Fixes a panic on a Synology NAS reported at https://github.com/rfjakob/gocryptfs/issues/145 --- internal/contentenc/content.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'internal/contentenc/content.go') diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go index f48080f..e6f79a6 100644 --- a/internal/contentenc/content.go +++ b/internal/contentenc/content.go @@ -194,6 +194,8 @@ func (be *ContentEnc) DecryptBlock(ciphertext []byte, blockNo uint64, fileID []b const encryptMaxSplit = 2 // EncryptBlocks is like EncryptBlock but takes multiple plaintext blocks. +// Returns a byte slice from CReqPool - so don't forget to return it +// to the pool. func (be *ContentEnc) EncryptBlocks(plaintextBlocks [][]byte, firstBlockNo uint64, fileID []byte) []byte { ciphertextBlocks := make([][]byte, len(plaintextBlocks)) // For large writes, we parallelize encryption. -- cgit v1.2.3