ole32: Return error instead of asserting if storage file is corrupt.
This commit is contained in:
parent
b61b82011e
commit
707fa2c3a2
|
@ -273,7 +273,7 @@ static HRESULT WINAPI StgStreamImpl_Read(
|
||||||
*/
|
*/
|
||||||
if (This->smallBlockChain!=0)
|
if (This->smallBlockChain!=0)
|
||||||
{
|
{
|
||||||
SmallBlockChainStream_ReadAt(This->smallBlockChain,
|
res = SmallBlockChainStream_ReadAt(This->smallBlockChain,
|
||||||
This->currentPosition,
|
This->currentPosition,
|
||||||
bytesToReadFromBuffer,
|
bytesToReadFromBuffer,
|
||||||
pv,
|
pv,
|
||||||
|
@ -282,7 +282,7 @@ static HRESULT WINAPI StgStreamImpl_Read(
|
||||||
}
|
}
|
||||||
else if (This->bigBlockChain!=0)
|
else if (This->bigBlockChain!=0)
|
||||||
{
|
{
|
||||||
BlockChainStream_ReadAt(This->bigBlockChain,
|
res = BlockChainStream_ReadAt(This->bigBlockChain,
|
||||||
This->currentPosition,
|
This->currentPosition,
|
||||||
bytesToReadFromBuffer,
|
bytesToReadFromBuffer,
|
||||||
pv,
|
pv,
|
||||||
|
@ -300,30 +300,19 @@ static HRESULT WINAPI StgStreamImpl_Read(
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (SUCCEEDED(res))
|
||||||
* We should always be able to read the proper amount of data from the
|
|
||||||
* chain.
|
|
||||||
*/
|
|
||||||
assert(bytesToReadFromBuffer == *pcbRead);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Advance the pointer for the number of positions read.
|
|
||||||
*/
|
|
||||||
This->currentPosition.u.LowPart += *pcbRead;
|
|
||||||
|
|
||||||
if(*pcbRead != cb)
|
|
||||||
{
|
{
|
||||||
WARN("read %ld instead of the required %ld bytes !\n", *pcbRead, cb);
|
/*
|
||||||
/*
|
* We should always be able to read the proper amount of data from the
|
||||||
* this used to return S_FALSE, however MSDN docu says that an app should
|
* chain.
|
||||||
* be prepared to handle error in case of stream end reached, as *some*
|
*/
|
||||||
* implementations *might* return an error (IOW: most do *not*).
|
assert(bytesToReadFromBuffer == *pcbRead);
|
||||||
* As some program fails on returning S_FALSE, I better use S_OK here.
|
|
||||||
*/
|
/*
|
||||||
res = S_OK;
|
* Advance the pointer for the number of positions read.
|
||||||
|
*/
|
||||||
|
This->currentPosition.u.LowPart += *pcbRead;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
res = S_OK;
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
TRACE("<-- %08lx\n", res);
|
TRACE("<-- %08lx\n", res);
|
||||||
|
|
|
@ -3414,7 +3414,8 @@ BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
|
||||||
ULARGE_INTEGER size, offset;
|
ULARGE_INTEGER size, offset;
|
||||||
ULONG cbRead, cbWritten, cbTotalRead, cbTotalWritten;
|
ULONG cbRead, cbWritten, cbTotalRead, cbTotalWritten;
|
||||||
ULONG propertyIndex;
|
ULONG propertyIndex;
|
||||||
BOOL successRead, successWrite;
|
BOOL successWrite;
|
||||||
|
HRESULT successRead;
|
||||||
StgProperty chainProperty;
|
StgProperty chainProperty;
|
||||||
BYTE *buffer;
|
BYTE *buffer;
|
||||||
BlockChainStream *bbTempChain = NULL;
|
BlockChainStream *bbTempChain = NULL;
|
||||||
|
@ -3463,7 +3464,7 @@ BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
|
||||||
|
|
||||||
offset.u.LowPart += This->smallBlockSize;
|
offset.u.LowPart += This->smallBlockSize;
|
||||||
|
|
||||||
} while (successRead && successWrite);
|
} while (SUCCEEDED(successRead) && successWrite);
|
||||||
HeapFree(GetProcessHeap(),0,buffer);
|
HeapFree(GetProcessHeap(),0,buffer);
|
||||||
|
|
||||||
assert(cbTotalRead == cbTotalWritten);
|
assert(cbTotalRead == cbTotalWritten);
|
||||||
|
@ -4397,6 +4398,9 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
|
||||||
blockNoInSequence--;
|
blockNoInSequence--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((blockNoInSequence > 0) && (blockIndex == BLOCK_END_OF_CHAIN))
|
||||||
|
return FALSE; /* We failed to find the starting block */
|
||||||
|
|
||||||
This->lastBlockNoInSequenceIndex = blockIndex;
|
This->lastBlockNoInSequenceIndex = blockIndex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5098,13 +5102,14 @@ ULONG SmallBlockChainStream_GetNextFreeBlock(
|
||||||
* bytesRead may be NULL.
|
* bytesRead may be NULL.
|
||||||
* Failure will be returned if the specified number of bytes has not been read.
|
* Failure will be returned if the specified number of bytes has not been read.
|
||||||
*/
|
*/
|
||||||
BOOL SmallBlockChainStream_ReadAt(
|
HRESULT SmallBlockChainStream_ReadAt(
|
||||||
SmallBlockChainStream* This,
|
SmallBlockChainStream* This,
|
||||||
ULARGE_INTEGER offset,
|
ULARGE_INTEGER offset,
|
||||||
ULONG size,
|
ULONG size,
|
||||||
void* buffer,
|
void* buffer,
|
||||||
ULONG* bytesRead)
|
ULONG* bytesRead)
|
||||||
{
|
{
|
||||||
|
HRESULT rc = S_OK;
|
||||||
ULARGE_INTEGER offsetInBigBlockFile;
|
ULARGE_INTEGER offsetInBigBlockFile;
|
||||||
ULONG blockNoInSequence =
|
ULONG blockNoInSequence =
|
||||||
offset.u.LowPart / This->parentStorage->smallBlockSize;
|
offset.u.LowPart / This->parentStorage->smallBlockSize;
|
||||||
|
@ -5127,9 +5132,9 @@ BOOL SmallBlockChainStream_ReadAt(
|
||||||
|
|
||||||
while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN))
|
while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN))
|
||||||
{
|
{
|
||||||
if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
|
rc = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex);
|
||||||
&blockIndex)))
|
if(FAILED(rc))
|
||||||
return FALSE;
|
return rc;
|
||||||
blockNoInSequence--;
|
blockNoInSequence--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5158,27 +5163,32 @@ BOOL SmallBlockChainStream_ReadAt(
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read those bytes in the buffer from the small block file.
|
* Read those bytes in the buffer from the small block file.
|
||||||
|
* The small block has already been identified so it shouldn't fail
|
||||||
|
* unless the file is corrupt.
|
||||||
*/
|
*/
|
||||||
BlockChainStream_ReadAt(This->parentStorage->smallBlockRootChain,
|
if (!BlockChainStream_ReadAt(This->parentStorage->smallBlockRootChain,
|
||||||
offsetInBigBlockFile,
|
offsetInBigBlockFile,
|
||||||
bytesToReadInBuffer,
|
bytesToReadInBuffer,
|
||||||
bufferWalker,
|
bufferWalker,
|
||||||
&bytesReadFromBigBlockFile);
|
&bytesReadFromBigBlockFile))
|
||||||
|
return STG_E_DOCFILECORRUPT;
|
||||||
|
|
||||||
assert(bytesReadFromBigBlockFile == bytesToReadInBuffer);
|
assert(bytesReadFromBigBlockFile == bytesToReadInBuffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step to the next big block.
|
* Step to the next big block.
|
||||||
*/
|
*/
|
||||||
if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
|
rc = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex);
|
||||||
return FALSE;
|
if(FAILED(rc))
|
||||||
|
return rc;
|
||||||
|
|
||||||
bufferWalker += bytesToReadInBuffer;
|
bufferWalker += bytesToReadInBuffer;
|
||||||
size -= bytesToReadInBuffer;
|
size -= bytesToReadInBuffer;
|
||||||
*bytesRead += bytesToReadInBuffer;
|
*bytesRead += bytesToReadInBuffer;
|
||||||
offsetInBlock = 0; /* There is no offset on the next block */
|
offsetInBlock = 0; /* There is no offset on the next block */
|
||||||
}
|
}
|
||||||
|
|
||||||
return (size == 0);
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -667,7 +667,7 @@ void SmallBlockChainStream_FreeBlock(
|
||||||
ULONG SmallBlockChainStream_GetNextFreeBlock(
|
ULONG SmallBlockChainStream_GetNextFreeBlock(
|
||||||
SmallBlockChainStream* This);
|
SmallBlockChainStream* This);
|
||||||
|
|
||||||
BOOL SmallBlockChainStream_ReadAt(
|
HRESULT SmallBlockChainStream_ReadAt(
|
||||||
SmallBlockChainStream* This,
|
SmallBlockChainStream* This,
|
||||||
ULARGE_INTEGER offset,
|
ULARGE_INTEGER offset,
|
||||||
ULONG size,
|
ULONG size,
|
||||||
|
|
|
@ -1691,6 +1691,7 @@
|
||||||
#define STG_E_SHAREREQUIRED _HRESULT_TYPEDEF_(0x80030106L)
|
#define STG_E_SHAREREQUIRED _HRESULT_TYPEDEF_(0x80030106L)
|
||||||
#define STG_E_NOTFILEBASEDSTORAGE _HRESULT_TYPEDEF_(0x80030107L)
|
#define STG_E_NOTFILEBASEDSTORAGE _HRESULT_TYPEDEF_(0x80030107L)
|
||||||
#define STG_E_EXTANTMARSHALLINGS _HRESULT_TYPEDEF_(0x80030108L)
|
#define STG_E_EXTANTMARSHALLINGS _HRESULT_TYPEDEF_(0x80030108L)
|
||||||
|
#define STG_E_DOCFILECORRUPT _HRESULT_TYPEDEF_(0x80030109L)
|
||||||
|
|
||||||
#define STG_E_STATUS_COPY_PROTECTION_FAILURE _HRESULT_TYPEDEF_(0x80030305L)
|
#define STG_E_STATUS_COPY_PROTECTION_FAILURE _HRESULT_TYPEDEF_(0x80030305L)
|
||||||
#define STG_E_CSS_AUTHENTICATION_FAILURE _HRESULT_TYPEDEF_(0x80030306L)
|
#define STG_E_CSS_AUTHENTICATION_FAILURE _HRESULT_TYPEDEF_(0x80030306L)
|
||||||
|
|
Loading…
Reference in New Issue