From bb6cfe109d7295c0c27a664dd6226cd38f7d40bb Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 24 Apr 2023 16:24:22 +0100 Subject: [PATCH] crypt: fix reading 0 length files In an earlier patch d5afcf9e34044e5b crypt: try not to return "unexpected EOF" error This introduced a bug for 0 length files which this fixes which only manifests if the io.Reader returns data and EOF which not all readers do. This was failing in the integration tests. --- backend/crypt/cipher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/crypt/cipher.go b/backend/crypt/cipher.go index c6cdb47c6..d0f8a658e 100644 --- a/backend/crypt/cipher.go +++ b/backend/crypt/cipher.go @@ -804,7 +804,7 @@ func (c *Cipher) newDecrypter(rc io.ReadCloser) (*decrypter, error) { if n < fileHeaderSize && err == io.EOF { // This read from 0..fileHeaderSize-1 bytes return nil, fh.finishAndClose(ErrorEncryptedFileTooShort) - } else if err != nil { + } else if err != io.EOF && err != nil { return nil, fh.finishAndClose(err) } // check the magic