summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-12-30 17:39:58 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-12-30 17:49:21 +0000
commit859b59ce572f5781f3e2fa9ae6416cfd65116ca3 (patch)
treeeafffc463236df835baa1853ddefe97d54ae08b0
parent0376706c11458c269d6736e17367ee3f0404c4e9 (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
-rw-r--r--sot/source/sdstor/stgstrms.cxx15
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() )