[Libreoffice-commits] .: 2 commits - sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri Jul 8 02:51:41 PDT 2011


 sw/source/filter/ww8/ww8par3.cxx |  291 +++++++++++++++++++--------------------
 sw/source/filter/ww8/ww8scan.cxx |  109 ++++++++++----
 sw/source/filter/ww8/ww8scan.hxx |    2 
 3 files changed, 221 insertions(+), 181 deletions(-)

New commits:
commit 24b43b43a0f061c0fd76b9339ddc99b791c649e8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 8 10:22:05 2011 +0100

    check font and list lengths

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index e6ec295..a772166 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -351,6 +351,8 @@ struct WW8LST   // nur DIE Eintraege, die WIR benoetigen!
                                                         //   true if the list should start numbering over
 };                                                      //   at the beginning of each section
 
+const sal_uInt32 cbLSTF=28;
+
 struct WW8LFO   // nur DIE Eintraege, die WIR benoetigen!
 {
     SwNumRule*      pNumRule;   // Parent NumRule
@@ -1059,8 +1061,8 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
     // LST und LFO gibts erst ab WW8
     if(    ( 8 > rFib.nVersion )
             || ( rFib.fcPlcfLst == rFib.fcPlfLfo )
-            || ( !rFib.lcbPlcfLst )
-            || ( !rFib.lcbPlfLfo ) ) return; // offensichtlich keine Listen da
+            || ( rFib.lcbPlcfLst < 2 )
+            || ( rFib.lcbPlfLfo < 2) ) return; // offensichtlich keine Listen da
 
     // Arrays anlegen
     pLFOInfos = new WW8LFOInfos;
@@ -1072,187 +1074,182 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
     // 1. PLCF LST auslesen und die Listen Vorlagen im Writer anlegen
     //
     bool bOk = checkSeek(rSt, rFib.fcPlcfLst);
+
+    if (!bOk)
+        return;
+
+    sal_uInt32 nRemainingPlcfLst = rFib.lcbPlcfLst;
+
     sal_uInt16 nListCount(0);
-    if (bOk)
-    {
-        rSt >> nListCount;
-        bOk = 0 < nListCount;
-    }
-    if( bOk )
+    rSt >> nListCount;
+    nRemainingPlcfLst -= 2;
+    bOk = nListCount > 0;
+
+    if (!bOk)
+        return;
+
+    //
+    // 1.1 alle LST einlesen
+    //
+    for (sal_uInt16 nList=0; nList < nListCount; ++nList)
     {
-        //
-        // 1.1 alle LST einlesen
-        //
-        for (sal_uInt16 nList=0; nList < nListCount; ++nList)
-        {
-            bOk = false;
+        if (nRemainingPlcfLst < cbLSTF)
+            break;
 
-            if (rSt.IsEof())
-                break;
+        WW8LST aLST;
+        memset(&aLST, 0, sizeof( aLST ));
 
-            WW8LST aLST;
-            memset(&aLST, 0, sizeof( aLST ));
-            //
-            // 1.1.1 Daten einlesen
-            //
-            rSt >> aLST.nIdLst;
-            rSt >> aLST.nTplC;
-            for (sal_uInt16 nLevel = 0; nLevel < nMaxLevel; ++nLevel)
-                rSt >> aLST.aIdSty[ nLevel ];
+        //
+        // 1.1.1 Daten einlesen
+        //
+        rSt >> aLST.nIdLst;
+        rSt >> aLST.nTplC;
+        for (sal_uInt16 nLevel = 0; nLevel < nMaxLevel; ++nLevel)
+            rSt >> aLST.aIdSty[ nLevel ];
 
-            sal_uInt8 aBits1(0);
-            rSt >> aBits1;
+        sal_uInt8 aBits1(0);
+        rSt >> aBits1;
 
-            rSt.SeekRel( 1 );
+        rSt.SeekRel( 1 );
 
-            if (rSt.GetError())
-                break;
+        if( aBits1 & 0x01 )
+            aLST.bSimpleList = true;
+        if( aBits1 & 0x02 )
+            aLST.bRestartHdn = true;
 
-            if( aBits1 & 0x01 )
-                aLST.bSimpleList = true;
-            if( aBits1 & 0x02 )
-                aLST.bRestartHdn = true;
+        // 1.1.2 new NumRule inserted in Doc and  WW8LSTInfo marked
 
-            // 1.1.2 new NumRule inserted in Doc and  WW8LSTInfo marked
+        /*
+        #i1869#
+        In word 2000 microsoft got rid of creating new "simple lists" with
+        only 1 level, all new lists are created with 9 levels. To hack it
+        so that the list types formerly known as simple lists still have
+        their own tab page to themselves one of the reserved bits is used
+        to show that a given list is to be in the simple list tabpage.
+        This has now nothing to do with the actual number of list level a
+        list has, only how many will be shown in the user interface.
+
+        i.e. create a simple list in 2000 and open it in 97 and 97 will
+        claim (correctly) that it is an outline list. We can set our
+        continous flag in these lists to store this information.
+        */
+        SwNumRule* pMyNumRule = CreateNextRule(
+            aLST.bSimpleList || (aBits1 & 0x10));
 
-            /*
-            #i1869#
-            In word 2000 microsoft got rid of creating new "simple lists" with
-            only 1 level, all new lists are created with 9 levels. To hack it
-            so that the list types formerly known as simple lists still have
-            their own tab page to themselves one of the reserved bits is used
-            to show that a given list is to be in the simple list tabpage.
-            This has now nothing to do with the actual number of list level a
-            list has, only how many will be shown in the user interface.
-
-            i.e. create a simple list in 2000 and open it in 97 and 97 will
-            claim (correctly) that it is an outline list. We can set our
-            continous flag in these lists to store this information.
-            */
-            SwNumRule* pMyNumRule = CreateNextRule(
-                aLST.bSimpleList || (aBits1 & 0x10));
+        WW8LSTInfo* pLSTInfo = new WW8LSTInfo(pMyNumRule, aLST);
+        maLSTInfos.push_back(pLSTInfo);
 
-            WW8LSTInfo* pLSTInfo = new WW8LSTInfo(pMyNumRule, aLST);
-            maLSTInfos.push_back(pLSTInfo);
-            bOk = true;
-        }
+        nRemainingPlcfLst -= cbLSTF;
     }
 
-    if( bOk )
+    //
+    // 1.2 alle LVL aller aLST einlesen
+    //
+    sal_uInt16 nLSTInfos = static_cast< sal_uInt16 >(maLSTInfos.size());
+    for (sal_uInt16 nList = 0; nList < nLSTInfos; ++nList)
     {
+        WW8LSTInfo* pListInfo = maLSTInfos[nList];
+        if( !pListInfo || !pListInfo->pNumRule ) break;
+        SwNumRule& rMyNumRule = *pListInfo->pNumRule;
         //
-        // 1.2 alle LVL aller aLST einlesen
+        // 1.2.1 betreffende(n) LVL(s) fuer diese aLST einlesen
         //
-        sal_uInt16 nLSTInfos = static_cast< sal_uInt16 >(maLSTInfos.size());
-        for (sal_uInt16 nList = 0; nList < nLSTInfos; ++nList)
+        sal_uInt16 nLvlCount = static_cast< sal_uInt16 >(pListInfo->bSimpleList ? nMinLevel : nMaxLevel);
+        std::deque<bool> aNotReallyThere;
+        aNotReallyThere.resize(nMaxLevel);
+        pListInfo->maParaSprms.resize(nMaxLevel);
+        for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
         {
-            bOk = false;
-            WW8LSTInfo* pListInfo = maLSTInfos[nList];
-            if( !pListInfo || !pListInfo->pNumRule ) break;
-            SwNumRule& rMyNumRule = *pListInfo->pNumRule;
-            //
-            // 1.2.1 betreffende(n) LVL(s) fuer diese aLST einlesen
-            //
-            sal_uInt16 nLvlCount = static_cast< sal_uInt16 >(pListInfo->bSimpleList ? nMinLevel : nMaxLevel);
-            std::deque<bool> aNotReallyThere;
-            aNotReallyThere.resize(nMaxLevel);
-            pListInfo->maParaSprms.resize(nMaxLevel);
-            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
-            {
-                SwNumFmt aNumFmt( rMyNumRule.Get( nLevel ) );
-                // LVLF einlesen
-                bLVLOk = ReadLVL( aNumFmt, pListInfo->aItemSet[nLevel],
-                    pListInfo->aIdSty[nLevel], true, aNotReallyThere, nLevel,
-                    pListInfo->maParaSprms[nLevel]);
-                if( !bLVLOk )
-                    break;
-                // und in die rMyNumRule aufnehmen
-                rMyNumRule.Set( nLevel, aNumFmt );
-            }
+            SwNumFmt aNumFmt( rMyNumRule.Get( nLevel ) );
+            // LVLF einlesen
+            bLVLOk = ReadLVL( aNumFmt, pListInfo->aItemSet[nLevel],
+                pListInfo->aIdSty[nLevel], true, aNotReallyThere, nLevel,
+                pListInfo->maParaSprms[nLevel]);
             if( !bLVLOk )
                 break;
-            //
-            // 1.2.2 die ItemPools mit den CHPx Einstellungen der verschiedenen
-            //       Level miteinander vergleichen und ggfs. Style(s) erzeugen
-            //
-            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
-            {
-                bool bDummy;
-                AdjustLVL( nLevel, rMyNumRule, pListInfo->aItemSet,
-                                               pListInfo->aCharFmt, bDummy );
-            }
-            //
-            // 1.2.3 ItemPools leeren und loeschen
-            //
-            for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
-                delete pListInfo->aItemSet[ nLevel ];
-            bOk = true;
+            // und in die rMyNumRule aufnehmen
+            rMyNumRule.Set( nLevel, aNumFmt );
         }
+        if( !bLVLOk )
+            break;
+        //
+        // 1.2.2 die ItemPools mit den CHPx Einstellungen der verschiedenen
+        //       Level miteinander vergleichen und ggfs. Style(s) erzeugen
+        //
+        for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
+        {
+            bool bDummy;
+            AdjustLVL( nLevel, rMyNumRule, pListInfo->aItemSet,
+                                           pListInfo->aCharFmt, bDummy );
+        }
+        //
+        // 1.2.3 ItemPools leeren und loeschen
+        //
+        for (sal_uInt8 nLevel = 0; nLevel < nLvlCount; ++nLevel)
+            delete pListInfo->aItemSet[ nLevel ];
     }
 
     //
     // 2. PLF LFO auslesen und speichern
     //
-    long nLfoCount(0);
+    bOk = checkSeek(rSt, rFib.fcPlfLfo);
 
-    if (bOk)
-        bOk = checkSeek(rSt, rFib.fcPlfLfo);
+    if (!bOk)
+        return;
 
-    if (bOk)
-    {
-        rSt >> nLfoCount;
-        if (0 >= nLfoCount)
-            bOk = false;
-    }
+    sal_Int32 nLfoCount(0);
+    rSt >> nLfoCount;
+    bOk = nLfoCount > 0;
+
+    if (!bOk)
+        return;
 
-    if(bOk)
+    //
+    // 2.1 alle LFO einlesen
+    //
+    for (sal_uInt16 nLfo = 0; nLfo < nLfoCount; ++nLfo)
     {
-        //
-        // 2.1 alle LFO einlesen
-        //
-        for (sal_uInt16 nLfo = 0; nLfo < nLfoCount; ++nLfo)
-        {
-            bOk = false;
+        bOk = false;
 
-            if (rSt.IsEof())
-                break;
+        if (rSt.IsEof())
+            break;
 
-            WW8LFO aLFO;
-            memset(&aLFO, 0, sizeof( aLFO ));
+        WW8LFO aLFO;
+        memset(&aLFO, 0, sizeof( aLFO ));
 
-            rSt >> aLFO.nIdLst;
-            rSt.SeekRel( 8 );
-            rSt >> aLFO.nLfoLvl;
-            rSt.SeekRel( 3 );
-            // soviele Overrides existieren
-            if ((nMaxLevel < aLFO.nLfoLvl) || rSt.GetError())
-                break;
+        rSt >> aLFO.nIdLst;
+        rSt.SeekRel( 8 );
+        rSt >> aLFO.nLfoLvl;
+        rSt.SeekRel( 3 );
+        // soviele Overrides existieren
+        if ((nMaxLevel < aLFO.nLfoLvl) || rSt.GetError())
+            break;
 
-            // die Parent NumRule der entsprechenden Liste ermitteln
-            WW8LSTInfo* pParentListInfo = GetLSTByListId(aLFO.nIdLst);
-            if (pParentListInfo)
-            {
-                // hier, im ersten Schritt, erst mal diese NumRule festhalten
-                aLFO.pNumRule = pParentListInfo->pNumRule;
+        // die Parent NumRule der entsprechenden Liste ermitteln
+        WW8LSTInfo* pParentListInfo = GetLSTByListId(aLFO.nIdLst);
+        if (pParentListInfo)
+        {
+            // hier, im ersten Schritt, erst mal diese NumRule festhalten
+            aLFO.pNumRule = pParentListInfo->pNumRule;
 
-                // hat die Liste mehrere Level ?
-                aLFO.bSimpleList = pParentListInfo->bSimpleList;
-            }
-            // und rein ins Merk-Array mit dem Teil
-            WW8LFOInfo* pLFOInfo = new WW8LFOInfo(aLFO);
-            if (pParentListInfo)
-            {
-                //Copy the basic paragraph properties for each level from the
-                //original list into the list format override levels.
-                int nMaxSize = pParentListInfo->maParaSprms.size();
-                pLFOInfo->maParaSprms.resize(nMaxSize);
-                for (int i = 0; i < nMaxSize; ++i)
-                    pLFOInfo->maParaSprms[i] = pParentListInfo->maParaSprms[i];
-            }
-            pLFOInfos->Insert(pLFOInfo, pLFOInfos->Count());
-            bOk = true;
+            // hat die Liste mehrere Level ?
+            aLFO.bSimpleList = pParentListInfo->bSimpleList;
+        }
+        // und rein ins Merk-Array mit dem Teil
+        WW8LFOInfo* pLFOInfo = new WW8LFOInfo(aLFO);
+        if (pParentListInfo)
+        {
+            //Copy the basic paragraph properties for each level from the
+            //original list into the list format override levels.
+            int nMaxSize = pParentListInfo->maParaSprms.size();
+            pLFOInfo->maParaSprms.resize(nMaxSize);
+            for (int i = 0; i < nMaxSize; ++i)
+                pLFOInfo->maParaSprms[i] = pParentListInfo->maParaSprms[i];
         }
+        pLFOInfos->Insert(pLFOInfo, pLFOInfos->Count());
+        bOk = true;
     }
+
     if( bOk )
     {
         //
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 7d9a2ef..f47b640 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2026,7 +2026,8 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
     const sal_uInt32 nValidMin=4;
 
     sal_Size nOldPos = pSt->Tell();
-    bool bValid = checkSeek(*pSt, nFilePos);
+
+    bool bValid = (nPLCF >= nValidMin) && checkSeek(*pSt, nFilePos);
     nPLCF = bValid ? std::max(nPLCF, nValidMin) : nValidMin;
 
     // Pointer auf Pos- u. Struct-Array
@@ -2350,7 +2351,8 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
     const sal_uInt32 nValidMin=4;
 
     sal_Size nOldPos = pSt->Tell();
-    bool bValid = checkSeek(*pSt, nFilePos);
+
+    bool bValid = (nPLCF >= nValidMin) && checkSeek(*pSt, nFilePos);
     nPLCF = bValid ? std::max(nPLCF, nValidMin) : nValidMin;
 
     pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ];    // Pointer auf Pos-Array
@@ -6213,6 +6215,7 @@ namespace
         while (nRemaining)
         {
             //p[0] is cbFfnM1, the alleged total length of FFN - 1.
+            //i.e. length after cbFfnM1
             sal_uInt16 cbFfnM1 = *p++;
             --nRemaining;
 
@@ -6292,7 +6295,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
 
                 p->wWeight   = ( *(((sal_uInt8*)pVer2) + 1) );
                 p->chs   = ( *(((sal_uInt8*)pVer2) + 2) );
-            /*
+                /*
                  #i8726# 7- seems to encode the name in the same encoding as
                  the font, e.g load the doc in 97 and save to see the unicode
                  ver of the asian fontnames in that example to confirm.
@@ -6352,48 +6355,80 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
         }
         else
         {
-            WW8_FFN_Ver8* pVer8 = (WW8_FFN_Ver8*)pA;
-            sal_uInt8 c2;
-            for(sal_uInt16 i=0; i<nMax; ++i, ++p)
+            //count of bytes in minimum FontFamilyInformation payload
+            const sal_uInt8 cbMinFFNPayload = 41;
+            sal_uInt16 nValidFonts = 0;
+            sal_Int32 nRemainingFFn = nFFn;
+            sal_uInt8* pRaw = pA;
+            for (sal_uInt16 i=0; i < nMax && nRemainingFFn; ++i, ++p)
             {
-                p->cbFfnM1   = pVer8->cbFfnM1;
-                c2           = *(((sal_uInt8*)pVer8) + 1);
+                //pRaw[0] is cbFfnM1, the alleged total length of FFN - 1
+                //i.e. length after cbFfnM1
+                sal_uInt8 cbFfnM1 = *pRaw++;
+                --nRemainingFFn;
 
-                p->prg       =  c2 & 0x02;
+                if (cbFfnM1 > nRemainingFFn)
+                    break;
+
+                if (cbFfnM1 < cbMinFFNPayload)
+                    break;
+
+                p->cbFfnM1 = cbFfnM1;
+
+                sal_uInt8 *pVer8 = pRaw;
+
+                sal_uInt8 c2 = *pVer8++;
+                --cbFfnM1;
+
+                p->prg = c2 & 0x02;
                 p->fTrueType = (c2 & 0x04) >> 2;
                 // ein Reserve-Bit ueberspringen
-                p->ff        = (c2 & 0x70) >> 4;
+                p->ff = (c2 & 0x70) >> 4;
 
-                p->wWeight   = SVBT16ToShort( *(SVBT16*)&pVer8->wWeight );
-                p->chs       = pVer8->chs;
-                p->ibszAlt   = pVer8->ibszAlt;
+                p->wWeight = SVBT16ToShort(*(SVBT16*)pVer8);
+                pVer8+=2;
+                cbFfnM1-=2;
 
-#ifdef __WW8_NEEDS_COPY
-                {
-                    sal_uInt8 nLen = 0x28;
-                    sal_uInt8 nLength = sizeof( pVer8->szFfn ) / sizeof( SVBT16 );
-                    nLength = std::min( nLength, sal_uInt8( pVer8->cbFfnM1+1 ) );
-                    for( sal_uInt16* pTmp = pVer8->szFfn;
-                        nLen < nLength; ++pTmp, nLen+=2 )
-                    {
-                        *pTmp = SVBT16ToShort( *(SVBT16*)pTmp );
-                    }
-                }
-#endif // defined __WW8_NEEDS_COPY
+                p->chs = *pVer8++;
+                --cbFfnM1;
 
-                p->sFontname = pVer8->szFfn;
-                if (p->ibszAlt)
+                p->ibszAlt = *pVer8++;
+                --cbFfnM1;
+
+                pVer8 += 10; //PANOSE
+                cbFfnM1-=10;
+                pVer8 += 24; //FONTSIGNATURE
+                cbFfnM1-=24;
+
+                OSL_ASSERT(cbFfnM1 >= 2);
+
+                sal_uInt8 nMaxNullTerminatedPossible = cbFfnM1/2 - 1;
+                sal_Unicode *pPrimary = reinterpret_cast<sal_Unicode*>(pVer8);
+                pPrimary[nMaxNullTerminatedPossible] = 0;
+#ifdef OSL_BIGENDIAN
+                swapEndian(pPrimary);
+#endif
+                p->sFontname = pPrimary;
+                if (p->ibszAlt && p->ibszAlt < nMaxNullTerminatedPossible)
                 {
                     p->sFontname.Append(';');
-                    p->sFontname.Append(pVer8->szFfn+p->ibszAlt);
+                    sal_Unicode *pSecondary = pPrimary + p->ibszAlt;
+#ifdef OSL_BIGENDIAN
+                    swapEndian(pSecondary);
+#endif
+                    p->sFontname.Append(pSecondary);
                 }
 
                 // #i43762# check font name for illegal characters
                 lcl_checkFontname( p->sFontname );
 
                 // Zeiger auf Ursprungsarray einen Font nach hinten setzen
-                pVer8 = (WW8_FFN_Ver8*)( ((sal_uInt8*)pVer8) + pVer8->cbFfnM1 + 1 );
+                pRaw += p->cbFfnM1;
+                nRemainingFFn -= p->cbFfnM1;
+                ++nValidFonts;
             }
+            OSL_ENSURE(nMax == nValidFonts, "Font count differs with availability");
+            nMax = std::min(nMax, nValidFonts);
         }
     }
     delete[] pA;
@@ -7368,4 +7403,10 @@ bool checkRead(SvStream &rSt, void *pDest, sal_uInt32 nLength)
     return (rSt.Read(pDest, nLength) == static_cast<sal_Size>(nLength));
 }
 
+void swapEndian(sal_Unicode *pString)
+{
+    for (sal_Unicode *pWork = pString; *pWork; ++pWork)
+        *pWork = SWAPSHORT(*pWork);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 7cdbb8c..c110b5a 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1789,6 +1789,8 @@ bool checkRead(SvStream &rSt, void *pDest, sal_uInt32 nLength);
 const sal_uInt16 lLetterWidth = 12242;
 const sal_uInt16 lLetterHeight = 15842;
 
+void swapEndian(sal_Unicode *pString);
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8a7f06da3e72dfe4a833e1ccb27d014c1fe9526a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 8 09:33:50 2011 +0100

    oops, brain fart

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 913a125..7d9a2ef 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2027,7 +2027,7 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
 
     sal_Size nOldPos = pSt->Tell();
     bool bValid = checkSeek(*pSt, nFilePos);
-    nPLCF = bValid ? std::min(nPLCF, nValidMin) : nValidMin;
+    nPLCF = bValid ? std::max(nPLCF, nValidMin) : nValidMin;
 
     // Pointer auf Pos- u. Struct-Array
     pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ];
@@ -2035,7 +2035,7 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
 
     nPLCF = bValid ? pSt->Read(pPLCF_PosArray, nPLCF) : nValidMin;
 
-    nPLCF = std::min(nPLCF, nValidMin);
+    nPLCF = std::max(nPLCF, nValidMin);
 
     nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
 #ifdef OSL_BIGENDIAN
@@ -2351,13 +2351,13 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
 
     sal_Size nOldPos = pSt->Tell();
     bool bValid = checkSeek(*pSt, nFilePos);
-    nPLCF = bValid ? std::min(nPLCF, nValidMin) : nValidMin;
+    nPLCF = bValid ? std::max(nPLCF, nValidMin) : nValidMin;
 
     pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ];    // Pointer auf Pos-Array
     pPLCF_PosArray[0] = 0;
 
     nPLCF = bValid ? pSt->Read(pPLCF_PosArray, nPLCF) : nValidMin;
-    nPLCF = std::min(nPLCF, nValidMin);
+    nPLCF = std::max(nPLCF, nValidMin);
 
     nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
 #ifdef OSL_BIGENDIAN
@@ -2478,7 +2478,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion, SvStream* pSt,
             break;
         }
 
-        unsigned int nOfs = maRawData[nRawDataStart] * 2;
+        unsigned int nOfs = maRawData[nRawDataOffset] * 2;
 
         //clip to available data, corrupt fkp
         if (nOfs >= 511)


More information about the Libreoffice-commits mailing list