Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2017-12-12 05:01:14 +0300
committerJonathan White <support@dmapps.us>2017-12-12 05:01:14 +0300
commitcf94610f46eaf77e0c1dc9e6abc5fea3e0d00f49 (patch)
tree9fb8afbcc17bf9f2299eb0be6e33415a7a7edb45 /src
parent6d46717cfc2d61bfc6a5335b02e95c6b1d9bf482 (diff)
parentc7836f11578a85f61a49bcdb35ae442046778dd1 (diff)
Release 2.2.32.2.3
- Prevent database corruption when locked [#1219] - Fixes apply button not saving new entries [#1141] - Switch to Consolas font on Windows for password edit [#1229] - Multiple fixes to AppImage deployment [#1115, #1228] - Fixes multiple memory leaks [#1213] - Resize message close to 16x16 pixels [#1253]
Diffstat (limited to 'src')
-rw-r--r--src/crypto/SymmetricCipherGcrypt.cpp2
-rw-r--r--src/format/KeePass2Repair.cpp37
-rw-r--r--src/format/KeePass2Repair.h8
-rw-r--r--src/gui/DatabaseOpenWidget.cpp18
-rw-r--r--src/gui/DatabaseOpenWidget.h1
-rw-r--r--src/gui/DatabaseRepairWidget.cpp6
-rw-r--r--src/gui/DatabaseTabWidget.cpp16
-rw-r--r--src/gui/DatabaseWidget.cpp2
-rw-r--r--src/gui/MainWindow.cpp2
-rw-r--r--src/gui/PasswordEdit.cpp13
-rw-r--r--src/gui/entry/EditEntryWidget.cpp4
-rw-r--r--src/gui/entry/EditEntryWidget.h1
12 files changed, 61 insertions, 49 deletions
diff --git a/src/crypto/SymmetricCipherGcrypt.cpp b/src/crypto/SymmetricCipherGcrypt.cpp
index e600a7edb..1805afb0b 100644
--- a/src/crypto/SymmetricCipherGcrypt.cpp
+++ b/src/crypto/SymmetricCipherGcrypt.cpp
@@ -86,6 +86,8 @@ bool SymmetricCipherGcrypt::init()
gcry_error_t error;
+ if(m_ctx != nullptr)
+ gcry_cipher_close(m_ctx);
error = gcry_cipher_open(&m_ctx, m_algo, m_mode, 0);
if (error != 0) {
setErrorString(error);
diff --git a/src/format/KeePass2Repair.cpp b/src/format/KeePass2Repair.cpp
index 81ada2fda..8d18457d4 100644
--- a/src/format/KeePass2Repair.cpp
+++ b/src/format/KeePass2Repair.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Felix Geyer <debfx@fobos.de>
+ * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,36 +19,29 @@
#include "KeePass2Repair.h"
#include <QBuffer>
+#include <QScopedPointer>
#include <QRegExp>
#include "format/KeePass2RandomStream.h"
#include "format/KeePass2Reader.h"
#include "format/KeePass2XmlReader.h"
-KeePass2Repair::KeePass2Repair()
- : m_db(nullptr)
+KeePass2Repair::RepairOutcome KeePass2Repair::repairDatabase(QIODevice* device, const CompositeKey& key)
{
-}
-
-KeePass2Repair::RepairResult KeePass2Repair::repairDatabase(QIODevice* device, const CompositeKey& key)
-{
- m_db = nullptr;
m_errorStr.clear();
KeePass2Reader reader;
reader.setSaveXml(true);
- Database* db = reader.readDatabase(device, key, true);
+ QScopedPointer<Database> db(reader.readDatabase(device, key, true));
if (!reader.hasError()) {
- delete db;
- return NothingTodo;
+ return qMakePair(NothingTodo, nullptr);
}
QByteArray xmlData = reader.xmlData();
if (!db || xmlData.isEmpty()) {
- delete db;
m_errorStr = reader.errorString();
- return UnableToOpen;
+ return qMakePair(UnableToOpen, nullptr);
}
bool repairAction = false;
@@ -59,8 +53,7 @@ KeePass2Repair::RepairResult KeePass2Repair::repairDatabase(QIODevice* device, c
&& encodingRegExp.cap(1).compare("utf8", Qt::CaseInsensitive) != 0)
{
// database is not utf-8 encoded, we don't support repairing that
- delete db;
- return RepairFailed;
+ return qMakePair(RepairFailed, nullptr);
}
}
@@ -75,8 +68,7 @@ KeePass2Repair::RepairResult KeePass2Repair::repairDatabase(QIODevice* device, c
if (!repairAction) {
// we were unable to find the problem
- delete db;
- return RepairFailed;
+ return qMakePair(RepairFailed, nullptr);
}
KeePass2RandomStream randomStream;
@@ -84,23 +76,16 @@ KeePass2Repair::RepairResult KeePass2Repair::repairDatabase(QIODevice* device, c
KeePass2XmlReader xmlReader;
QBuffer buffer(&xmlData);
buffer.open(QIODevice::ReadOnly);
- xmlReader.readDatabase(&buffer, db, &randomStream);
+ xmlReader.readDatabase(&buffer, db.data(), &randomStream);
if (xmlReader.hasError()) {
- delete db;
- return RepairFailed;
+ return qMakePair(RepairFailed, nullptr);
}
else {
- m_db = db;
- return RepairSuccess;
+ return qMakePair(RepairSuccess, db.take());
}
}
-Database* KeePass2Repair::database() const
-{
- return m_db;
-}
-
QString KeePass2Repair::errorString() const
{
return m_errorStr;
diff --git a/src/format/KeePass2Repair.h b/src/format/KeePass2Repair.h
index fe2f9dbfe..e7f2c8435 100644
--- a/src/format/KeePass2Repair.h
+++ b/src/format/KeePass2Repair.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Felix Geyer <debfx@fobos.de>
+ * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +21,7 @@
#include <QCoreApplication>
#include <QIODevice>
+#include <QPair>
#include "core/Database.h"
#include "keys/CompositeKey.h"
@@ -36,14 +38,12 @@ public:
RepairSuccess,
RepairFailed
};
+ using RepairOutcome = QPair<RepairResult, Database*>;
- KeePass2Repair();
- RepairResult repairDatabase(QIODevice* device, const CompositeKey& key);
- Database* database() const;
+ RepairOutcome repairDatabase(QIODevice* device, const CompositeKey& key);
QString errorString() const;
private:
- Database* m_db;
QString m_errorStr;
};
diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp
index ee0e9de26..e487f97ca 100644
--- a/src/gui/DatabaseOpenWidget.cpp
+++ b/src/gui/DatabaseOpenWidget.cpp
@@ -95,11 +95,16 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event)
m_ui->editPassword->setFocus();
#ifdef WITH_XC_YUBIKEY
- connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
- connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
- connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
-
- pollYubikey();
+ // showEvent() may be called twice, so make sure we are only polling once
+ if (!m_yubiKeyBeingPolled) {
+ connect(YubiKey::instance(), SIGNAL(detected(int, bool)), SLOT(yubikeyDetected(int, bool)),
+ Qt::QueuedConnection);
+ connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
+ connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
+
+ pollYubikey();
+ m_yubiKeyBeingPolled = true;
+ }
#endif
}
@@ -110,6 +115,7 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
#ifdef WITH_XC_YUBIKEY
// Don't listen to any Yubikey events if we are hidden
disconnect(YubiKey::instance(), 0, this, 0);
+ m_yubiKeyBeingPolled = false;
#endif
}
@@ -311,10 +317,12 @@ void DatabaseOpenWidget::yubikeyDetectComplete()
m_ui->checkChallengeResponse->setEnabled(true);
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
+ m_yubiKeyBeingPolled = false;
}
void DatabaseOpenWidget::noYubikeyFound()
{
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
+ m_yubiKeyBeingPolled = false;
}
diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h
index a7691a91e..aade111c3 100644
--- a/src/gui/DatabaseOpenWidget.h
+++ b/src/gui/DatabaseOpenWidget.h
@@ -73,6 +73,7 @@ protected:
QString m_filename;
private:
+ bool m_yubiKeyBeingPolled = false;
Q_DISABLE_COPY(DatabaseOpenWidget)
};
diff --git a/src/gui/DatabaseRepairWidget.cpp b/src/gui/DatabaseRepairWidget.cpp
index 2b0039408..d3dddf14f 100644
--- a/src/gui/DatabaseRepairWidget.cpp
+++ b/src/gui/DatabaseRepairWidget.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Felix Geyer <debfx@fobos.de>
+ * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -69,7 +70,8 @@ void DatabaseRepairWidget::openDatabase()
delete m_db;
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- KeePass2Repair::RepairResult repairResult = repair.repairDatabase(&file, masterKey);
+ auto repairOutcome = repair.repairDatabase(&file, masterKey);
+ KeePass2Repair::RepairResult repairResult = repairOutcome.first;
QApplication::restoreOverrideCursor();
switch (repairResult) {
@@ -83,7 +85,7 @@ void DatabaseRepairWidget::openDatabase()
emit editFinished(false);
return;
case KeePass2Repair::RepairSuccess:
- m_db = repair.database();
+ m_db = repairOutcome.second;
MessageBox::warning(this, tr("Success"), tr("The database has been successfully repaired\nYou can now save it."));
emit editFinished(true);
return;
diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp
index 4c9445ccc..f70df4c79 100644
--- a/src/gui/DatabaseTabWidget.cpp
+++ b/src/gui/DatabaseTabWidget.cpp
@@ -298,8 +298,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
if (!saveDatabase(db)) {
return false;
}
- }
- else {
+ } else if (dbStruct.dbWidget->currentMode() != DatabaseWidget::LockedMode) {
QMessageBox::StandardButton result =
MessageBox::question(
this, tr("Save changes?"),
@@ -307,10 +306,9 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Yes);
if (result == QMessageBox::Yes) {
if (!saveDatabase(db)) {
- return false;
+ return false;
}
- }
- else if (result == QMessageBox::Cancel) {
+ } else if (result == QMessageBox::Cancel) {
return false;
}
}
@@ -355,8 +353,13 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
{
DatabaseManagerStruct& dbStruct = m_dbList[db];
- if (dbStruct.saveToFilename) {
+ if (dbStruct.dbWidget->currentMode() == DatabaseWidget::LockedMode) {
+ // Never allow saving a locked database; it causes corruption
+ // We return true since a save is not required
+ return true;
+ }
+ if (dbStruct.saveToFilename) {
dbStruct.dbWidget->blockAutoReload(true);
QString errorMessage = db->saveToFile(dbStruct.canonicalFilePath);
dbStruct.dbWidget->blockAutoReload(false);
@@ -375,7 +378,6 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
MessageWidget::Error);
return false;
}
-
} else {
return saveDatabaseAs(db);
}
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 3a39bddcf..453b2009b 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -1125,7 +1125,7 @@ void DatabaseWidget::onWatchedFileChanged()
void DatabaseWidget::reloadDatabaseFile()
{
- if (m_db == nullptr)
+ if (m_db == nullptr || currentMode() == DatabaseWidget::LockedMode)
return;
if (! config()->get("AutoReloadOnChange").toBool()) {
diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index f1d5f866c..e37a7d28c 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -881,7 +881,7 @@ void MainWindow::toggleWindow()
raise();
activateWindow();
-#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS)
+#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS) && (QT_VERSION < QT_VERSION_CHECK(5, 9, 0))
// re-register global D-Bus menu (needed on Ubuntu with Unity)
// see https://github.com/keepassxreboot/keepassxc/issues/271
// and https://bugreports.qt.io/browse/QTBUG-58723
diff --git a/src/gui/PasswordEdit.cpp b/src/gui/PasswordEdit.cpp
index 54b0ca288..ad736bf20 100644
--- a/src/gui/PasswordEdit.cpp
+++ b/src/gui/PasswordEdit.cpp
@@ -31,9 +31,18 @@ PasswordEdit::PasswordEdit(QWidget* parent)
{
setEchoMode(QLineEdit::Password);
updateStylesheet();
-
- // set font to system monospace font and increase letter spacing
+
+ // use a monospace font for the password field
QFont passwordFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+#ifdef Q_OS_WIN
+ // try to use Consolas on Windows, because the default Courier New has too many similar characters
+ QFont consolasFont = QFontDatabase().font("Consolas", passwordFont.styleName(), passwordFont.pointSize());
+ const QFont defaultFont;
+ if (passwordFont != defaultFont) {
+ passwordFont = consolasFont;
+ }
+#endif
+
passwordFont.setLetterSpacing(QFont::PercentageSpacing, 110);
setFont(passwordFont);
}
diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index 809ac95eb..5a058bda4 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -278,6 +278,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
m_database = database;
m_create = create;
m_history = history;
+ m_saved = false;
if (history) {
setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history")));
@@ -438,6 +439,7 @@ void EditEntryWidget::saveEntry()
}
updateEntryData(m_entry);
+ m_saved = true;
if (!m_create) {
m_entry->endUpdate();
@@ -510,7 +512,7 @@ void EditEntryWidget::cancel()
clear();
- emit editFinished(false);
+ emit editFinished(m_saved);
}
void EditEntryWidget::clear()
diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h
index 2888d43a8..628f8f8ed 100644
--- a/src/gui/entry/EditEntryWidget.h
+++ b/src/gui/entry/EditEntryWidget.h
@@ -121,6 +121,7 @@ private:
bool m_create;
bool m_history;
+ bool m_saved;
const QScopedPointer<Ui::EditEntryWidgetMain> m_mainUi;
const QScopedPointer<Ui::EditEntryWidgetAdvanced> m_advancedUi;
const QScopedPointer<Ui::EditEntryWidgetAutoType> m_autoTypeUi;