keepassium / KeePassium

KeePass-compatible password manager for iOS
https://keepassium.com
Other
1.21k stars 103 forks source link

New attachments seem corrupted until database is reloaded #211

Closed layandreas closed 2 years ago

layandreas commented 2 years ago

Description .pfx file is corrupted after saving as attachment.

How to reproduce Steps to reproduce the behavior:

  1. Create database
  2. Create entry
  3. Add .pfx file as attachment
  4. Save database
  5. Download .pfx from databse

Expected behavior The saved file should not be corrupted.

Screenshots

Original .pfx file:

Screenshot 2021-12-17 at 17 02 16

File from database (file size is actually slightly less than the original file):

Screenshot 2021-12-17 at 17 08 56

Environment:

keepassium commented 2 years ago

I can reproduce this, definitely an issue.

When saving the database, KeePassium gzip-compresses the attachments. When loading the database, the app decompresses them. Apparently, for new files compression applies to the actual data (instead of a copy). That's why the file looks slightly smaller and starts with gzip signature (1F8B08).

Once you close and reopen the database, all the attachments are decompressed and look fine. (I guess that's why you closed the issue?)

I have also tested adding two attachments in a row, and the first one was compressed only once. After reloading the database both attachments were fine.

So while not a critical issue (attachments in the database are fine), this is still a very valid issue. I will get this fixed. Thanks, Andreas.