Kunzisoft / KeePassDX

Lightweight vault and password manager for Android, KeePassDX allows editing encrypted data in a single file in KeePass format and fill in the forms in a secure way.
https://www.keepassdx.com/
GNU General Public License v3.0
4.6k stars 269 forks source link

Can't modify or open database on KeepassDX #1442

Closed hectour3 closed 11 months ago

hectour3 commented 1 year ago

I recently moved to Android and wanted to use my Keepass database with KeepassDX. When I first open the file everything is fine, but when trying to add a new entry it gives an error that the file can not be saved. After locking and then trying to unlock the database again I get the error "Could not load your database. java.lang.NegativeArraySizeException: -1" . Once this error occurs it stays and the only way to open the database is to redownload it fresh from my cloud provider.

I created the file with KeepassXC and set the encryption level at its highest. It uses KDBX 4. Most of the data in it was imported from 1Password.

J-Jamet commented 1 year ago

Your problem is undoubtedly with your cloud provider, can you tell us what it is? In order to fill in the wiki summary table in detail. https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync

hectour3 commented 1 year ago

I m pretty sure that is not the problem. I tried to create an entry when the file is saved on ProtonDrive, and then it indeed rightaway gives me the error that the file could not be saved. I then put a fresh copy of the file in my local downloads directory, opened it, tried to add an entry. It tries to save it for about 10 seconds and gives me the warning not to kill the app. I then get the error that the file could not be saved. If I then lock the file and try to unlock it again it gives me the error "Could not load your database. java.lang.NegativeArraySizeException: -1"

J-Jamet commented 1 year ago

It's weird, I've never had this kind of problem with a local file. The exceptions raised with "Could not load your database." can be a database content provider issue but also a key file issue, can you tell me what is the format of the URI you are trying to open? (ie : "content://...)

hectour3 commented 1 year ago

content://com.android.providers.downloads.documents/document/17

It seems that the error "Could not load your database. java.lang.NegativeArraySizeException: -1" is the result of a corruption of the file. When I put a fresh copy in the downloads directory it opens fine. The error occurs after I have tried to add a new entry, which fails, and then try to open the file again after locking.

It seems to me that the issue might be with the my database file. When I create a database in the app and then add entries it works fine. Can you think of any things that have to do with the file that might cause this?

J-Jamet commented 11 months ago

To resolve the bad formatting of your .kdbx file you can use KeePass2 for PC, export your database in xml and reimport it, which will rebuild the database.