From 8e7fa3d3d6d9295eabac0f4de6b1eb1220dab277 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sat, 23 Sep 2017 11:45:20 -0400 Subject: [PATCH] Corrected multiple Yubikey bugs (#880) * Fixed database not showing modified after failed save * Fixed Yubikey not being redetected after replug * Fixed single shot challenge resulting in failed saves --- src/gui/DatabaseTabWidget.cpp | 2 ++ src/keys/YkChallengeResponseKey.cpp | 4 ++-- src/keys/drivers/YubiKey.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index e13158eac..9dca1ac06 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -363,6 +363,8 @@ bool DatabaseTabWidget::saveDatabase(Database* db) emit messageDismissTab(); return true; } else { + dbStruct.modified = true; + updateTabName(db); emit messageTab(tr("Writing the database failed.").append("\n").append(errorMessage), MessageWidget::Error); return false; diff --git a/src/keys/YkChallengeResponseKey.cpp b/src/keys/YkChallengeResponseKey.cpp index cfb4a1dfe..4c77e7670 100644 --- a/src/keys/YkChallengeResponseKey.cpp +++ b/src/keys/YkChallengeResponseKey.cpp @@ -50,7 +50,7 @@ QByteArray YkChallengeResponseKey::rawKey() const */ bool YkChallengeResponseKey::challenge(const QByteArray& challenge) { - return this->challenge(challenge, 1); + return this->challenge(challenge, 2); } bool YkChallengeResponseKey::challenge(const QByteArray& challenge, unsigned retries) @@ -70,8 +70,8 @@ bool YkChallengeResponseKey::challenge(const QByteArray& challenge, unsigned ret QEventLoop loop; QFutureWatcher watcher; - watcher.setFuture(future); connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); + watcher.setFuture(future); loop.exec(); if (m_blocking) { diff --git a/src/keys/drivers/YubiKey.cpp b/src/keys/drivers/YubiKey.cpp index 6fb44ec89..b6f0d3098 100644 --- a/src/keys/drivers/YubiKey.cpp +++ b/src/keys/drivers/YubiKey.cpp @@ -154,7 +154,7 @@ YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByte QByteArray paddedChallenge = challenge; // ensure that YubiKey::init() succeeded - if (m_yk == NULL) { + if (!init()) { m_mutex.unlock(); return ERROR; }