From d6857e654f10a6d451df5546c07e63ae7859e2ed Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Thu, 16 Jul 2020 18:45:30 -0400 Subject: [PATCH] Fix minor TOTP issues * Fix #5105 - prevent divide-by-zero segfault due to invalid TOTP settings * Clear TOTP settings if attributes are removed --- src/core/Entry.cpp | 2 ++ src/totp/totp.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 65a271c2..0322d353 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -481,6 +481,8 @@ void Entry::updateTotp() m_attributes->value(Totp::ATTRIBUTE_SEED)); } else if (m_attributes->contains(Totp::ATTRIBUTE_OTP)) { m_data.totpSettings = Totp::parseSettings(m_attributes->value(Totp::ATTRIBUTE_OTP)); + } else { + m_data.totpSettings.reset(); } } diff --git a/src/totp/totp.cpp b/src/totp/totp.cpp index 105196fc..1936cce7 100644 --- a/src/totp/totp.cpp +++ b/src/totp/totp.cpp @@ -113,7 +113,7 @@ QSharedPointer Totp::parseSettings(const QString& rawSettings, c } // Bound digits and step - settings->digits = qMax(1u, settings->digits); + settings->digits = qBound(1u, settings->digits, 10u); settings->step = qBound(1u, settings->step, 60u); // Detect custom settings, used by setup GUI