aboutsummaryrefslogtreecommitdiff
path: root/internal/contentenc/content.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-10-17 21:47:32 +0200
committerJakob Unterwurzacher2017-10-17 21:48:29 +0200
commit3009ec9852316c3c696f77f476390ab5a6d8d6d7 (patch)
treee64b84f0cdda14b32fe986918aeae7f7be465a4d /internal/contentenc/content.go
parent64e5906ffa1f225a51048b3d0ac6b1a09e2ca170 (diff)
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
Diffstat (limited to 'internal/contentenc/content.go')
-rw-r--r--internal/contentenc/content.go2
1 files changed, 2 insertions, 0 deletions
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.