mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Handle FileKey::load errors (--key-file) (#825)
This commit is contained in:
parent
ece6969edf
commit
fe877486ff
@ -402,24 +402,28 @@ Database* Database::openDatabaseFile(QString fileName, CompositeKey key)
|
||||
|
||||
Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename)
|
||||
{
|
||||
CompositeKey compositeKey;
|
||||
|
||||
if (!keyFilename.isEmpty()) {
|
||||
FileKey fileKey;
|
||||
QString errorMessage;
|
||||
if (!fileKey.load(keyFilename, &errorMessage)) {
|
||||
qCritical("Failed to load key file %s : %s", qPrintable(keyFilename), qPrintable(errorMessage));
|
||||
return nullptr;
|
||||
}
|
||||
compositeKey.addKey(fileKey);
|
||||
}
|
||||
|
||||
QTextStream outputTextStream(stdout);
|
||||
|
||||
outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> ");
|
||||
outputTextStream.flush();
|
||||
|
||||
CompositeKey compositeKey;
|
||||
|
||||
QString line = Utils::getPassword();
|
||||
PasswordKey passwordKey;
|
||||
passwordKey.setPassword(line);
|
||||
compositeKey.addKey(passwordKey);
|
||||
|
||||
if (!keyFilename.isEmpty()) {
|
||||
FileKey fileKey;
|
||||
fileKey.load(keyFilename);
|
||||
compositeKey.addKey(fileKey);
|
||||
}
|
||||
|
||||
return Database::openDatabaseFile(databaseFilename, compositeKey);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user