From b6eeabab5ecddc78af41fac111e370036db0de7f Mon Sep 17 00:00:00 2001 From: Carlo Teubner <435950+c4rlo@users.noreply.github.com> Date: Sun, 2 Dec 2018 15:05:54 +0000 Subject: [PATCH] KeePass2Reader: fix error message logic (#2523) --- src/format/KeePass2Reader.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/format/KeePass2Reader.cpp b/src/format/KeePass2Reader.cpp index b62e398d9..97c361abe 100644 --- a/src/format/KeePass2Reader.cpp +++ b/src/format/KeePass2Reader.cpp @@ -64,22 +64,25 @@ bool KeePass2Reader::readDatabase(QIODevice* device, QSharedPointer 'Import KeePass 1 database...'.\n" "This is a one-way migration. You won't be able to open the imported " "database with the old KeePassX 0.4 version.")); return false; + } else if (!(signature1 == KeePass2::SIGNATURE_1 && signature2 == KeePass2::SIGNATURE_2)) { + raiseError(tr("Not a KeePass database.")); + return false; } + // mask out minor version + m_version &= KeePass2::FILE_VERSION_CRITICAL_MASK; + quint32 maxVersion = KeePass2::FILE_VERSION_4 & KeePass2::FILE_VERSION_CRITICAL_MASK; if (m_version < KeePass2::FILE_VERSION_MIN || m_version > maxVersion) { raiseError(tr("Unsupported KeePass 2 database version."));