diff --git a/src/format/KeePass1Reader.cpp b/src/format/KeePass1Reader.cpp index 21448ef81..f69febd2c 100644 --- a/src/format/KeePass1Reader.cpp +++ b/src/format/KeePass1Reader.cpp @@ -198,6 +198,11 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor delete entry; } else { + quint32 groupId = m_entryGroupIds.value(entry); + if (!m_groupIds.contains(groupId)) { + return 0; + } + entry->setGroup(m_groupIds.value(groupId)); entry->setUuid(Uuid::random()); } } @@ -540,7 +545,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream) return 0; } quint32 groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER); - entry->setGroup(m_groupIds.value(groupId)); + m_entryGroupIds.insert(entry.data(), groupId); break; } case 0x0003: diff --git a/src/format/KeePass1Reader.h b/src/format/KeePass1Reader.h index c90328288..e94ab3b0a 100644 --- a/src/format/KeePass1Reader.h +++ b/src/format/KeePass1Reader.h @@ -76,6 +76,7 @@ private: QHash m_groupIds; QHash m_groupLevels; QHash m_entryUuids; + QHash m_entryGroupIds; bool m_error; QString m_errorStr; diff --git a/tests/TestKeePass1Reader.cpp b/tests/TestKeePass1Reader.cpp index 587204131..def8c6e65 100644 --- a/tests/TestKeePass1Reader.cpp +++ b/tests/TestKeePass1Reader.cpp @@ -47,6 +47,8 @@ void TestKeePass1Reader::initTestCase() void TestKeePass1Reader::testBasic() { + QVERIFY(m_db->deletedObjects().isEmpty()); + QCOMPARE(m_db->rootGroup()->children().size(), 2); Group* group1 = m_db->rootGroup()->children().at(0);