ole32: Do not allow the same stream to be opened twice.

This commit is contained in:
Vincent Povirk 2009-11-18 10:38:10 -06:00 committed by Alexandre Julliard
parent 53128d522b
commit 371f6a4818
2 changed files with 26 additions and 2 deletions

View File

@ -110,6 +110,8 @@ static BOOL StorageImpl_WriteDWordToBigBlock( StorageImpl* This,
static BOOL StorageImpl_ReadDWordFromBigBlock( StorageImpl* This,
ULONG blockIndex, ULONG offset, DWORD* value);
static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEntry);
/* OLESTREAM memory structure to use for Get and Put Routines */
/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
typedef struct
@ -453,6 +455,13 @@ static HRESULT WINAPI StorageBaseImpl_OpenStream(
if ( (streamEntryRef!=DIRENTRY_NULL) &&
(currentEntry.stgType==STGTY_STREAM) )
{
if (StorageBaseImpl_IsStreamOpen(This, streamEntryRef))
{
/* A single stream cannot be opened a second time. */
res = STG_E_ACCESSDENIED;
goto end;
}
newStream = StgStreamImpl_Construct(This, grfMode, streamEntryRef);
if (newStream!=0)
@ -1807,6 +1816,21 @@ void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm)
list_remove(&(strm->StrmListEntry));
}
static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEntry)
{
StgStreamImpl *strm;
LIST_FOR_EACH_ENTRY(strm, &stg->strmHead, StgStreamImpl, StrmListEntry)
{
if (strm->dirEntry == streamEntry)
{
return TRUE;
}
}
return FALSE;
}
static void StorageBaseImpl_DeleteAll(StorageBaseImpl * stg)
{
struct list *cur, *cur2;

View File

@ -1100,13 +1100,13 @@ static void test_substorage_share(void)
if (r == S_OK)
{
r = IStorage_OpenStream(stg, stmname, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stm2);
todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStream should fail %08x\n", r);
ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStream should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stm2);
r = IStorage_OpenStream(stg, stmname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm2);
todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStream should fail %08x\n", r);
ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStream should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stm2);