mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 23:39:50 -05:00
When parsing make sure that databases contain at least the root group.
This commit is contained in:
parent
3be7fa6b3b
commit
e16720d06d
@ -51,12 +51,18 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
|
||||
|
||||
m_tmpParent = new Group();
|
||||
|
||||
bool rootGroupParsed = false;
|
||||
|
||||
if (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "KeePassFile") {
|
||||
parseKeePassFile();
|
||||
rootGroupParsed = parseKeePassFile();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_xml.error() && !rootGroupParsed) {
|
||||
raiseError(28);
|
||||
}
|
||||
|
||||
if (!m_xml.error()) {
|
||||
if (!m_tmpParent->children().isEmpty()) {
|
||||
qWarning("KeePass2XmlReader::readDatabase: found %d invalid group reference(s)",
|
||||
@ -141,21 +147,25 @@ QByteArray KeePass2XmlReader::headerHash()
|
||||
return m_headerHash;
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseKeePassFile()
|
||||
bool KeePass2XmlReader::parseKeePassFile()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "KeePassFile");
|
||||
|
||||
bool rootParsed = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Meta") {
|
||||
parseMeta();
|
||||
}
|
||||
else if (m_xml.name() == "Root") {
|
||||
parseRoot();
|
||||
rootParsed = parseRoot();
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
return rootParsed;
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseMeta()
|
||||
@ -409,10 +419,12 @@ void KeePass2XmlReader::parseCustomDataItem()
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseRoot()
|
||||
bool KeePass2XmlReader::parseRoot()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Root");
|
||||
|
||||
bool groupParsed = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Group") {
|
||||
Group* rootGroup = parseGroup();
|
||||
@ -420,6 +432,7 @@ void KeePass2XmlReader::parseRoot()
|
||||
Group* oldRoot = m_db->rootGroup();
|
||||
m_db->setRootGroup(rootGroup);
|
||||
delete oldRoot;
|
||||
groupParsed = true;
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "DeletedObjects") {
|
||||
@ -429,6 +442,8 @@ void KeePass2XmlReader::parseRoot()
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
return groupParsed;
|
||||
}
|
||||
|
||||
Group* KeePass2XmlReader::parseGroup()
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
QByteArray headerHash();
|
||||
|
||||
private:
|
||||
void parseKeePassFile();
|
||||
bool parseKeePassFile();
|
||||
void parseMeta();
|
||||
void parseMemoryProtection();
|
||||
void parseCustomIcons();
|
||||
@ -57,7 +57,7 @@ private:
|
||||
void parseBinaries();
|
||||
void parseCustomData();
|
||||
void parseCustomDataItem();
|
||||
void parseRoot();
|
||||
bool parseRoot();
|
||||
Group* parseGroup();
|
||||
void parseDeletedObjects();
|
||||
void parseDeletedObject();
|
||||
|
Loading…
Reference in New Issue
Block a user