From 78c125af4ee37bb3eb15140be9fe96da24dddf4a Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 12 Oct 2012 12:09:22 +0200 Subject: [PATCH] Check if all required database headers were present. --- src/format/KeePass2Reader.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/format/KeePass2Reader.cpp b/src/format/KeePass2Reader.cpp index f6818f4b2..3eb3fe977 100644 --- a/src/format/KeePass2Reader.cpp +++ b/src/format/KeePass2Reader.cpp @@ -45,6 +45,12 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke m_error = false; m_errorStr = QString(); m_headerEnd = false; + m_xmlData.clear(); + m_masterSeed.clear(); + m_transformSeed.clear(); + m_encryptionIV.clear(); + m_streamStartBytes.clear(); + m_protectedStreamKey.clear(); StoreDataStream headerStream(m_device); headerStream.open(QIODevice::ReadOnly); @@ -77,7 +83,13 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke headerStream.close(); - // TODO: check if all header fields have been parsed + // check if all required headers were present + if (m_masterSeed.isEmpty() || m_transformSeed.isEmpty() || m_encryptionIV.isEmpty() + || m_streamStartBytes.isEmpty() || m_protectedStreamKey.isEmpty() + || m_db->cipher().isNull()) { + raiseError(""); + return Q_NULLPTR; + } m_db->setKey(key, m_transformSeed, false);