Merge pull request #1231 from ONLYOFFICE/hotfix/v7.4.1

Fix bug 63357
This commit is contained in:
Oleg Korshul
2023-07-14 13:22:39 +05:00
committed by GitHub
4 changed files with 47 additions and 44 deletions

View File

@ -330,6 +330,17 @@ public:
{
if (m_arFilesInManifest.find(*i) == m_arFilesInManifest.end())
{
// пустые файлы нет смысла добавлять
std::wstring sFile = *i;
CManifestFileInfo oInfo;
oInfo.m_pFolder = m_pFolder;
oInfo.SetFilePath(sFile);
std::string sXmlRels = m_pFolder->readXml(sFile);
COOXMLRelationships _rels(sXmlRels, &oInfo);
if (0 == _rels.rels.size())
continue;
m_valid = OOXML_SIGNATURE_INVALID;
break;
}
@ -346,8 +357,8 @@ public:
oInfo.m_pFolder = m_pFolder;
oInfo.SetFilePath(sFile);
std::string sXml = m_pFolder->readXml(sFile);
COOXMLRelationships _rels(sXml, &oInfo);
std::string sXmlRels = m_pFolder->readXml(sFile);
COOXMLRelationships _rels(sXmlRels, &oInfo);
for (std::vector<COOXMLRelationship>::const_iterator relsIter = _rels.rels.begin(); relsIter != _rels.rels.end(); relsIter++)
{
@ -529,12 +540,6 @@ public:
sCalcValue = m_cert->GetHash(sXml, nAlg);
sValue = U_TO_UTF8((node.ReadNodeText(L"DigestValue")));
MakeBase64_NOCRLF(sValue);
// нельзя иметь ссылки на несуществующие файлы, так как это может быть использовано как взлом
// добавили стили, удалили файл - подписали - и можно подкидывать ЛЮБОЙ styles.xml и подпись будет валидной.
// так же можно подменять картинки и любой другой контент внешний.
if (oInfo.IsExitRemovedFile())
sCalcValue = "";
}
if (sCalcValue != sValue)

View File

@ -37,20 +37,11 @@ public:
m_sAliasDirectory = NSFile::GetDirectoryName(m_sAliasDirectory); // ../ from _rels/
}
void CheckAliasExist(const std::wstring& sFile)
{
if (!m_pFolder->exists(GetHeadPath(sFile)))
++m_nCountUnexistedFile;
}
bool IsExitRemovedFile()
{
return (0 != m_nCountUnexistedFile) ? true : false;
}
std::wstring GetHeadPath(const std::wstring& sFile)
{
return m_sAliasDirectory + L"/" + sFile;
std::wstring sFullPath = m_sAliasDirectory + L"/" + sFile;
sFullPath = L"/" + NSSystemPath::NormalizePath(sFullPath);
return sFullPath;
}
};
@ -166,11 +157,6 @@ public:
if (check_need->find(sRid) != check_need->end())
rels.push_back(oCurrentRel);
}
if (oCurrentRel.target_mode == L"Internal")
{
m_pFileInfo->CheckAliasExist(oCurrentRel.target);
}
}
}