mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-03 10:00:04 -05:00
CLI: fix missing check for correct credentials (#2629)
* CLI: fix missing check for correct credentials Before this fix, most/all CLI commands had incorrect behaviour when bad credentials were supplied: they would carry on regardless, with potentially catastrophic results. In particular, the "add" subcommand seemed to corrupt the database. "ls" would always report an empty database. Haven't tested any others. Also fixed a related missing check specific to the "merge" subcommand.
This commit is contained in:
parent
b59fd6d06a
commit
94430c300b
@ -79,6 +79,9 @@ int Merge::execute(const QStringList& arguments)
|
||||
QSharedPointer<Database> db2;
|
||||
if (!parser.isSet("same-credentials")) {
|
||||
db2 = Utils::unlockDatabase(args.at(1), parser.value(keyFileFromOption), Utils::STDOUT, Utils::STDERR);
|
||||
if (!db2) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
db2 = QSharedPointer<Database>::create();
|
||||
QString errorMessage;
|
||||
|
@ -135,8 +135,13 @@ QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
}
|
||||
|
||||
auto db = QSharedPointer<Database>::create();
|
||||
db->open(databaseFilename, compositeKey, nullptr, false);
|
||||
return db;
|
||||
QString error;
|
||||
if (db->open(databaseFilename, compositeKey, &error, false)) {
|
||||
return db;
|
||||
} else {
|
||||
err << error << endl;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user