[Libreoffice-commits] .: 2 commits - sw/source
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Jul 20 02:04:47 PDT 2011
sw/source/filter/ww8/WW8Sttbf.cxx | 17 ++++++++++-------
sw/source/filter/ww8/ww8par3.cxx | 13 +++++++------
sw/source/filter/ww8/ww8scan.cxx | 22 ++++++++++++++--------
3 files changed, 31 insertions(+), 21 deletions(-)
New commits:
commit e9c8beb4467fe352ff1ac482d5b99116607d11ce
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jul 20 09:57:31 2011 +0100
check for short reads
diff --git a/sw/source/filter/ww8/WW8Sttbf.cxx b/sw/source/filter/ww8/WW8Sttbf.cxx
index f8edb7f..5325dda 100644
--- a/sw/source/filter/ww8/WW8Sttbf.cxx
+++ b/sw/source/filter/ww8/WW8Sttbf.cxx
@@ -29,6 +29,7 @@
#include <iostream>
#include <dbgoutsw.hxx>
#include "WW8Sttbf.hxx"
+#include "ww8scan.hxx"
#include <cstdio>
#include <osl/endian.h>
#include <rtl/ustrbuf.hxx>
@@ -40,17 +41,19 @@
namespace ww8
{
WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
- : mn_offset(0), mn_size(nSize)
+ : mn_offset(0), mn_size(0)
{
- rSt.Seek(nPos);
-
- mp_data.reset(new sal_uInt8[nSize]);
- rSt.Read(mp_data.get(), nSize);
+ if (checkSeek(rSt, nPos))
+ {
+ mp_data.reset(new sal_uInt8[nSize]);
+ mn_size = rSt.Read(mp_data.get(), nSize);
+ }
+ OSL_ENSURE(mn_size == nSize, "short read in WW8Struct::WW8Struct");
}
WW8Struct::WW8Struct(WW8Struct * pStruct, sal_uInt32 nPos, sal_uInt32 nSize)
- : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos),
- mn_size(nSize)
+ : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos)
+ , mn_size(nSize)
{
}
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 485083d..5bfd5de 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -1518,31 +1518,36 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode,
WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF )
{
if ( ((8 > pWw8Fib->nVersion) && !pWwF->fComplex) || !pWwF->lcbClx )
- return 0;
+ return NULL;
WW8_FC nClxPos = pWwF->fcClx;
sal_Int32 nClxLen = pWwF->lcbClx;
sal_Int32 nLeft = nClxLen;
sal_Int16 nGrpprl = 0;
- sal_uInt8 clxt;
- pStr->Seek( nClxPos );
+ if (!checkSeek(*pStr, nClxPos))
+ return NULL;
+
while( 1 ) // Zaehle Zahl der Grpprls
{
+ sal_uInt8 clxt(2);
*pStr >> clxt;
nLeft--;
if( 2 == clxt ) // PLCFfpcd ?
break; // PLCFfpcd gefunden
if( 1 == clxt ) // clxtGrpprl ?
nGrpprl++;
- sal_uInt16 nLen;
+ sal_uInt16 nLen(0);
*pStr >> nLen;
nLeft -= 2 + nLen;
if( nLeft < 0 )
return 0; // schiefgegangen
pStr->SeekRel( nLen ); // ueberlies grpprl
}
- pStr->Seek( nClxPos );
+
+ if (!checkSeek(*pStr, nClxPos))
+ return NULL;
+
nLeft = nClxLen;
pPieceGrpprls = new sal_uInt8*[nGrpprl + 1];
memset( pPieceGrpprls, 0, ( nGrpprl + 1 ) * sizeof(sal_uInt8 *) );
@@ -1550,11 +1555,12 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF )
sal_Int16 nAktGrpprl = 0; // lies Grpprls ein
while( 1 )
{
+ sal_uInt8 clxt(2);
*pStr >> clxt;
nLeft--;
if( 2 == clxt) // PLCFfpcd ?
break; // PLCFfpcd gefunden
- sal_uInt16 nLen;
+ sal_uInt16 nLen(0);
*pStr >> nLen;
nLeft -= 2 + nLen;
if( nLeft < 0 )
@@ -1570,10 +1576,10 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF )
pStr->SeekRel( nLen ); // ueberlies nicht-Grpprl
}
// lies Piece Table PLCF ein
- sal_Int32 nPLCFfLen;
+ sal_Int32 nPLCFfLen(0);
if (pWwF->GetFIBVersion() <= ww::eWW2)
{
- sal_Int16 nWordTwoLen;
+ sal_Int16 nWordTwoLen(0);
*pStr >> nWordTwoLen;
nPLCFfLen = nWordTwoLen;
}
commit 5393c0d0d3170fc1ba03f2ac86e107ceeb999305
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Jul 19 21:35:42 2011 +0100
use SprmIterator here too instead of hand-rolled loop
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index a772166..f715359 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -684,14 +684,15 @@ bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet,
// spezielle ItemSet relevant ist - und nicht ein Stack oder Style!
sal_uInt16 nOldFlags1 = rReader.GetToggleAttrFlags();
sal_uInt16 nOldFlags2 = rReader.GetToggleBiDiAttrFlags();
- short nLen = aLVL.nLenGrpprlChpx;
- sal_uInt8* pSprms1 = &aGrpprlChpx[0];
- while (0 < nLen)
+
+ WW8SprmIter aSprmIter(&aGrpprlChpx[0], aLVL.nLenGrpprlChpx,
+ maSprmParser);
+ while (const sal_uInt8* pSprm = aSprmIter.GetSprms())
{
- sal_uInt16 nL1 = rReader.ImportSprm( pSprms1 );
- nLen = nLen - nL1;
- pSprms1 += nL1;
+ rReader.ImportSprm(pSprm);
+ aSprmIter.advance();
}
+
// Reader-ItemSet-Pointer und Reader-Style zuruecksetzen
rReader.SetAktItemSet( 0 );
rReader.SetNAktColl( nOldColl );
More information about the Libreoffice-commits
mailing list