diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-12-30 17:39:58 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-12-30 17:53:40 +0000 |
commit | dc5383e2fa487a7599f2e317bba409dc3cde8339 (patch) | |
tree | 888c41806e8539778368052bf20af4b2ed6622b5 /sot | |
parent | dcf947534778520bad32167f181b42ef6a451531 (diff) |
fdo#84229 - don't set error when seeking beyond end of valid data.
XclImpStream and elsewhere does an initial seek to the end, then a
tell to work out the true length of the stream. In order to let us
attempt to rescue data from the beginning of otherwise corrupt /
truncated streams, we should avoid setting an error here.
Interestingly, we also (probably) don't want to return the true length
of the valid data - as this is how SotStorage has worked historically.
Change-Id: Ie0ff0e183220b81871ae3bf83980a24b57ac8694
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index b857c6de4888..0dbfe367c3fe 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -357,12 +357,16 @@ void StgStrm::scanBuildPageChainCache(sal_Int32 *pOptionalCalcSize) //returned second is false if it already exists if (!nUsedPageNumbers.insert(nBgn).second) + { + SAL_WARN ("sot", "Error: page number " << nBgn << " already in chain for stream"); bError = true; + } nOptSize += nPageSize; } if (bError) { + SAL_WARN("sot", "returning wrong format error"); if (pOptionalCalcSize) rIo.SetError( ERRCODE_IO_WRONGFORMAT ); m_aPagesCache.clear(); @@ -424,11 +428,18 @@ bool StgStrm::Pos2Page( sal_Int32 nBytePos ) if ( nIdx > m_aPagesCache.size() ) { - rIo.SetError( SVSTREAM_FILEFORMAT_ERROR ); + SAL_WARN("sot", "seek to index " << nIdx << + " beyond page cache size " << m_aPagesCache.size()); + // fdo#84229 - handle seek to end and back as eg. XclImpStream expects + nIdx = m_aPagesCache.size(); nPage = STG_EOF; - nOffset = nPageSize; + nOffset = 0; + // Intriguingly in the past we didn't reset nPos to match the real + // length of the stream thus: nPos = nPageSize * nIdx; so retain + // this behavior for now. return false; } + // special case: seek to 1st byte of new, unallocated page // (in case the file size is a multiple of the page size) if( nBytePos == nSize && !nOffset && nIdx > 0 && nIdx == m_aPagesCache.size() ) |