diff options
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/msfilter/dffrecordheader.cxx | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/filter/source/msfilter/dffrecordheader.cxx b/filter/source/msfilter/dffrecordheader.cxx index 2a8c91a89b1b..c94bec53b611 100644 --- a/filter/source/msfilter/dffrecordheader.cxx +++ b/filter/source/msfilter/dffrecordheader.cxx @@ -22,28 +22,21 @@ bool ReadDffRecordHeader(SvStream& rIn, DffRecordHeader& rRec) { rRec.nFilePos = rIn.Tell(); - if (rIn.remainingSize() >= 8) - { - sal_uInt16 nTmp(0); - rIn.ReadUInt16(nTmp); - rRec.nImpVerInst = nTmp; - rRec.nRecVer = sal::static_int_cast<sal_uInt8>(nTmp & 0x000F); - rRec.nRecInstance = nTmp >> 4; - rIn.ReadUInt16(rRec.nRecType); - rIn.ReadUInt32(rRec.nRecLen); + sal_uInt16 nTmp(0); + rIn.ReadUInt16(nTmp); + rRec.nImpVerInst = nTmp; + rRec.nRecVer = sal::static_int_cast<sal_uInt8>(nTmp & 0x000F); + rRec.nRecInstance = nTmp >> 4; + rRec.nRecType = 0; + rIn.ReadUInt16(rRec.nRecType); + rRec.nRecLen = 0; + rIn.ReadUInt32(rRec.nRecLen); + + // preserving overflow, optimally we would check + // the record size against the parent header + if (rRec.nRecLen > (SAL_MAX_UINT32 - rRec.nFilePos)) + rIn.SetError(SVSTREAM_FILEFORMAT_ERROR); - // preserving overflow, optimally we would check - // the record size against the parent header - if (rRec.nRecLen > (SAL_MAX_UINT32 - rRec.nFilePos)) - rIn.SetError(SVSTREAM_FILEFORMAT_ERROR); - } - else - { - rRec.nImpVerInst = 0; - rRec.nRecVer = 0; - rRec.nRecInstance = 0; - rIn.Seek(STREAM_SEEK_TO_END); - } return rIn.good(); } |