From 5950003f34a9a7668792dbcc196664627f2426bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Wed, 5 Dec 2012 13:16:32 +0000
Subject: [PATCH 13/14] Resolves: fdo#57532 restrict page sanity check to
 non-storage chunks

Change-Id: I47c24131e95b9a8a691dbff4710869ba91df8306
(cherry picked from commit 4a1044229afd6b52ca10e5c55f1957b153a8c6ea)
Reviewed-on: https://gerrit.libreoffice.org/1246
Reviewed-by: Michael Meeks <michael.meeks@suse.com>
Tested-by: Michael Meeks <michael.meeks@suse.com>
---
 sot/qa/cppunit/data/pass/fdo57532-1.compound |  Bin 0 -> 25088 bytes
 sot/source/sdstor/stgelem.cxx                |    2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 create mode 100644 sot/qa/cppunit/data/pass/fdo57532-1.compound

diff --git a/sot/qa/cppunit/data/pass/fdo57532-1.compound b/sot/qa/cppunit/data/pass/fdo57532-1.compound
new file mode 100644
index 0000000000000000000000000000000000000000..70068fe10c893813cdd0fa95a83a7326f69c9c32
GIT binary patch
literal 25088
zcmeHPdu&@*8UOCJojPsZrb&~&x6>}`Gxg#=lQOzEuQpwqge0XP3d2cm8W+d*t{uAY
zQh)*#+8<>b4^5LcrdCKWO=V0738n#p{eyslK!|@(ktS53Nn~ZBVp?l{zjJ*Z+i{>N
zl<~Ny{oV8WzVn^)oyWcBoX@%Z^A%UV`pvb!moj%yd~!2aEmcM72Et8lyhbF9Fw<`4
zaycgN01))te~|`WyZ8fnuT%#`g0(NR6GhOoaDMdfB9Ub>e0uowpHKYxgibAaRQnrb
zQN73)-f3tAd`|X?5-MkmG$1XPTVBYSFYFS$UkAQ~TF}ui4l}Jbz-Oty(n-?K&H4OF
zehVl*fc&NKPs1mlOBY=%(t=_A`8@x8{xkXfG_*ul?w^KEO{6E_(-r%ae*x()z<+nO
z;|C$P5%H-dB5y$cL`dX2h&Le}N}l7~_PcV+33~JOqQ425E}iSMT)G$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ccS&
z%?!9s7}aHg+jWcaS8QDQ^lzmco;&Hm3oioGDq6tOdi8ePGRz(WjBXunr3{{Px$;jy
z`!+0O%k6V-r5w_%Mf*8lId5;Z{p91{ZKeyrn37h(G{I!w^Y;g1x=u`)wdHrH=RUXI
zhW^*F7%m=gfjKQ-SbbU`pX=5_^nVWp=j9tXE29Bw8s>Dva+)~{a<!1p5zqB<A^LYE
zIZ|oIorTRb=VD?(@*6Pv+_ujrzb!xSTt6!E%xh1!$*VJtWwf`B7HjbTD{SD+>cb13
ztu9}?`Tj1mU+YYbOiozIto|lAHb|Q`B<ab-aM;Zcx5yi<FFd@Uq3jXA4I20x*N%qU

literal 0
HcmV?d00001

diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx
index e0d738a..2ceea4d 100644
--- a/sot/source/sdstor/stgelem.cxx
+++ b/sot/source/sdstor/stgelem.cxx
@@ -412,7 +412,7 @@ sal_Bool StgEntry::Load( const void* pFrom, sal_uInt32 nBufSize )
     if (n > nMaxLegalStr)
         return sal_False;
 
-    if ((nSize < 0 && cType != STG_STORAGE) || (nPage1 < 0 && !isKnownSpecial(nPage1)))
+    if ((cType != STG_STORAGE) && ((nSize < 0) || (nPage1 < 0 && !isKnownSpecial(nPage1))))
     {
         // the size makes no sense for the substorage
         // TODO/LATER: actually the size should be an unsigned value, but in this case it would mean a stream of more than 2Gb
-- 
1.7.10.4

