Commit 371f6a48 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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

parent 53128d52
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment