From b5ca7099c10504aa82ca13d055494bdcbe637f45 Mon Sep 17 00:00:00 2001 From: eelke Date: Fri, 8 Jul 2022 19:54:18 +0200 Subject: [PATCH] Catch botan exception in password manager and throw higher level exception. --- core/PasswordManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/PasswordManager.cpp b/core/PasswordManager.cpp index 44b0c5f..1e3eb1e 100644 --- a/core/PasswordManager.cpp +++ b/core/PasswordManager.cpp @@ -171,9 +171,17 @@ std::string PasswordManager::encrypt(const std::string &name, const std::string std::string PasswordManager::decrypt(const std::string &id, const std::string_view &encpwd) { - if (m_cryptoEngine) { - secure_vector decoded = m_cryptoEngine->get(id, encpwd); - return std::string(reinterpret_cast(decoded.data()), decoded.size()); + if (m_cryptoEngine) + { + try + { + secure_vector decoded = m_cryptoEngine->get(id, encpwd); + return std::string(reinterpret_cast(decoded.data()), decoded.size()); + } + catch (const Botan::Exception &ex) + { + throw PasswordManagerException(ex.what()); + } } else { throw PasswordManagerLockedException();