summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-08-24 12:36:41 +0100
committerDavid Tardon <dtardon@redhat.com>2015-08-25 07:15:31 +0000
commitcce05bd5e655ae1db7165e086183371bf071dae3 (patch)
tree4bf680b78efac7aa0cdb5f7cb31e21fb643f307f /sw
parentd92c8638a186900711faa88be5bed254b0574712 (diff)
guard against hangs with bogus unsorted plcfs
This reverts commit 6d21cbd1238556535ec1bb1adf35b25bc8eb898b. Change-Id: I309302ab5357b8404ee4c75bd0bfcb4f816e0588 (cherry picked from commit 74c0f74422671f8005f2cfc0ae94e5656bcea31e) Reviewed-on: https://gerrit.libreoffice.org/17951 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/data/ww5/pass/hang-1.docbin0 -> 4290 bytes
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx17
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx1
3 files changed, 18 insertions, 0 deletions
diff --git a/sw/qa/core/data/ww5/pass/hang-1.doc b/sw/qa/core/data/ww5/pass/hang-1.doc
new file mode 100644
index 000000000000..603372406e18
--- /dev/null
+++ b/sw/qa/core/data/ww5/pass/hang-1.doc
Binary files differ
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 496e81a2842d..1dbf102e8834 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2125,6 +2125,8 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
#endif // OSL_BIGENDIAN
// Pointer to content array
pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+
+ TruncToSortedRange();
}
OSL_ENSURE(bValid, "Document has corrupt PLCF, ignoring it");
@@ -2144,6 +2146,21 @@ void WW8PLCF::MakeFailedPLCF()
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)
{
OSL_ENSURE( nIMax < ncpN, "Pcl.Fkp: Why is PLCF too big?" );
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index e1002f77baa2..9b258af0d22f 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -291,6 +291,7 @@ private:
void MakeFailedPLCF();
+ void TruncToSortedRange();
public:
WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
WW8_CP nStartPos = -1);