Skip to content

Unexpected EOF while decrypting a file #431

Answered by magical
3c7 asked this question in Q&A
Discussion options

You must be logged in to vote

In your attachment encryption loop, you call defer w.Close().

https://github.com/3c7/age-encrypted-notebook/blob/1e57ce9cd739e1b2ed6604aff48ba32732ef5de3/internal/model/model.go#L194

These deferred calls run at the end of the function, not at the end of each loop iteration, so the writer is not being properly closed before you append the ciphertext to the encryptedAttachments list.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@3c7
Comment options

@FiloSottile
Comment options

Answer selected by 3c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants