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
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2022-08-12 04:59:12 +0300
committerJonathan White <support@dmapps.us>2022-09-11 15:30:22 +0300
commit13c5a8527ea9d450dce5098d0253156b3a618323 (patch)
tree18081921f70374ad4e2c5d2f55283f1d5d37c546
parent139e6ac78d45223e0bb125595f1e3211c06410e5 (diff)
Fix Windows Hello bugs
* Fix #7977 - wrap key signing request in try/catch block to prevent crashes on some machines. * Fix #8120 - try 3 times to bring Windows Hello prompt to front. This may be necessary on older machines that are slow to bring up the prompt window. Also remove defunct code on macOS to prevent window focus issues.
-rw-r--r--src/gui/Application.cpp6
-rw-r--r--src/winhello/WindowsHello.cpp30
2 files changed, 20 insertions, 16 deletions
diff --git a/src/gui/Application.cpp b/src/gui/Application.cpp
index c2c42c24d..d8769b98a 100644
--- a/src/gui/Application.cpp
+++ b/src/gui/Application.cpp
@@ -209,12 +209,6 @@ bool Application::event(QEvent* event)
emit openFile(static_cast<QFileOpenEvent*>(event)->file());
return true;
}
-#ifdef Q_OS_MACOS
- // restore main window when clicking on the docker icon
- else if (event->type() == QEvent::ApplicationActivate) {
- emit applicationActivated();
- }
-#endif
return QApplication::event(event);
}
diff --git a/src/winhello/WindowsHello.cpp b/src/winhello/WindowsHello.cpp
index 7095c72ee..99e798c50 100644
--- a/src/winhello/WindowsHello.cpp
+++ b/src/winhello/WindowsHello.cpp
@@ -41,6 +41,7 @@ using namespace Windows::Storage::Streams;
namespace
{
const std::wstring s_winHelloKeyName{L"keepassxc_winhello"};
+ int g_promptFocusCount = 0;
void queueSecurityPromptFocus(int delay = 500)
{
@@ -48,7 +49,11 @@ namespace
auto hWnd = ::FindWindowA("Credential Dialog Xaml Host", nullptr);
if (hWnd) {
::SetForegroundWindow(hWnd);
+ } else if (++g_promptFocusCount <= 3) {
+ queueSecurityPromptFocus();
+ return;
}
+ g_promptFocusCount = 0;
});
}
@@ -71,18 +76,23 @@ namespace
return false;
}
- const auto signature = result.Credential().RequestSignAsync(challengeBuffer).get();
- if (signature.Status() != KeyCredentialStatus::Success) {
- error = QObject::tr("Failed to sign challenge using Windows Hello.");
+ try {
+ const auto signature = result.Credential().RequestSignAsync(challengeBuffer).get();
+ if (signature.Status() != KeyCredentialStatus::Success) {
+ error = QObject::tr("Failed to sign challenge using Windows Hello.");
+ return false;
+ }
+
+ // Use the SHA-256 hash of the challenge signature as the encryption key
+ const auto response = signature.Result();
+ CryptoHash hasher(CryptoHash::Sha256);
+ hasher.addData({reinterpret_cast<const char*>(response.data()), static_cast<int>(response.Length())});
+ key = hasher.result();
+ return true;
+ } catch (winrt::hresult_error const& ex) {
+ error = QString::fromStdString(winrt::to_string(ex.message()));
return false;
}
-
- // Use the SHA-256 hash of the challenge signature as the encryption key
- const auto response = signature.Result();
- CryptoHash hasher(CryptoHash::Sha256);
- hasher.addData({reinterpret_cast<const char*>(response.data()), static_cast<int>(response.Length())});
- key = hasher.result();
- return true;
});
}
} // namespace