Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeePass2Reader: fix error message logic #2523

Merged
merged 1 commit into from
Dec 2, 2018

Conversation

c4rlo
Copy link
Contributor

@c4rlo c4rlo commented Dec 1, 2018

Bug found via lgtm.com.

Type of change

  • ✅ Bug fix (non-breaking change which fixes an issue)

Description and Context

Fix error message when attempting to open a KeePass 1 database.

While I was at it, I also introduced a dedicated error message for I/O errors when attempting to read the file signature (though this is secondary and doesn't matter much).

Testing strategy

make test continues to pass.

Other than that, I've tested this manually, by attempting to open files /dev/null, CHANGELOG, and tests/data/basic.kdb.

Before my change

The error message in all three cases is:

Unable to open the database:
Error while reading the database: Not a KeePass database.

After my change

For /dev/null:

Unable to open the database:
Error while reading the database: Failed to read database file.

For CHANGELOG:

Unable to open the database:
Error while reading the database: Not a KeePass database.

For tests/data/basic.kdb:

Unable to open the database:
Error while reading the database: The selected file is an old KeePass 1 database (.kdb).

You can import it by clicking on Database > 'Import KeePass 1 database...'.
This is a one-way migration. You won't be able to open the imported database with the old KeePassX 0.4 version.

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@droidmonkey
Copy link
Member

Can you create a database that matches the signature1/signature2 conditions to elicit the import error message?

@c4rlo
Copy link
Contributor Author

c4rlo commented Dec 1, 2018

Like my comment says above, tests/data/basic.kdb is such a database.

@droidmonkey
Copy link
Member

I need to get my (non-existent) glasses checked! I glossed right over that last part of your PR.

@droidmonkey droidmonkey requested a review from phoerious December 1, 2018 19:08
@phoerious
Copy link
Member

Wait the tests did pass before... Shouldn't they have failed of this is an issue?

@droidmonkey
Copy link
Member

I think the issue is that the specific error message about being a KeePass1 database that must be imported was not being displayed. The parser correctly failed, just did not display the right error for the human.

@c4rlo
Copy link
Contributor Author

c4rlo commented Dec 2, 2018

That's correct.

@phoerious
Copy link
Member

I see. Go on then.

@droidmonkey droidmonkey merged commit b6eeaba into keepassxreboot:develop Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants