Kaydet (Commit) 74c0f744 authored tarafından Caolán McNamara's avatar Caolán McNamara

guard against hangs with bogus unsorted plcfs

This reverts commit 6d21cbd1.

Change-Id: I309302ab5357b8404ee4c75bd0bfcb4f816e0588
üst 6d21cbd1
This diff was suppressed by a .gitattributes entry.
...@@ -2101,6 +2101,8 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF) ...@@ -2101,6 +2101,8 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
#endif // OSL_BIGENDIAN #endif // OSL_BIGENDIAN
// Pointer to content array // Pointer to content array
pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]); pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
TruncToSortedRange();
} }
OSL_ENSURE(bValid, "Document has corrupt PLCF, ignoring it"); OSL_ENSURE(bValid, "Document has corrupt PLCF, ignoring it");
...@@ -2120,6 +2122,21 @@ void WW8PLCF::MakeFailedPLCF() ...@@ -2120,6 +2122,21 @@ void WW8PLCF::MakeFailedPLCF()
pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]); pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
} }
void WW8PLCF::TruncToSortedRange()
{
//Docs state that: ... all Plcs ... are sorted in ascending order.
//So ensure that here for broken documents.
for (auto nI = 0; nI < nIMax; ++nI)
{
if (pPLCF_PosArray[nI] > pPLCF_PosArray[nI+1])
{
SAL_WARN("sw.ww8", "Document has unsorted PLCF, truncated to sorted portion");
nIMax = nI;
break;
}
}
}
void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN) void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
{ {
OSL_ENSURE( nIMax < ncpN, "Pcl.Fkp: Why is PLCF too big?" ); OSL_ENSURE( nIMax < ncpN, "Pcl.Fkp: Why is PLCF too big?" );
......
...@@ -291,6 +291,7 @@ private: ...@@ -291,6 +291,7 @@ private:
void MakeFailedPLCF(); void MakeFailedPLCF();
void TruncToSortedRange();
public: public:
WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct, WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
WW8_CP nStartPos = -1); WW8_CP nStartPos = -1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment