mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-31 10:39:14 -04:00
Handle FileKey::load errors (--key-file) (#825)
This commit is contained in:
parent
ece6969edf
commit
fe877486ff
1 changed files with 12 additions and 8 deletions
|
@ -402,24 +402,28 @@ Database* Database::openDatabaseFile(QString fileName, CompositeKey key)
|
||||||
|
|
||||||
Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename)
|
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);
|
QTextStream outputTextStream(stdout);
|
||||||
|
|
||||||
outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> ");
|
outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> ");
|
||||||
outputTextStream.flush();
|
outputTextStream.flush();
|
||||||
|
|
||||||
CompositeKey compositeKey;
|
|
||||||
|
|
||||||
QString line = Utils::getPassword();
|
QString line = Utils::getPassword();
|
||||||
PasswordKey passwordKey;
|
PasswordKey passwordKey;
|
||||||
passwordKey.setPassword(line);
|
passwordKey.setPassword(line);
|
||||||
compositeKey.addKey(passwordKey);
|
compositeKey.addKey(passwordKey);
|
||||||
|
|
||||||
if (!keyFilename.isEmpty()) {
|
|
||||||
FileKey fileKey;
|
|
||||||
fileKey.load(keyFilename);
|
|
||||||
compositeKey.addKey(fileKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Database::openDatabaseFile(databaseFilename, compositeKey);
|
return Database::openDatabaseFile(databaseFilename, compositeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue