ole32: Forbid opening the same storage twice.

This commit is contained in:
Vincent Povirk 2009-11-19 13:55:34 -06:00 committed by Alexandre Julliard
parent d3c0a3a829
commit c62a4ad841
2 changed files with 25 additions and 2 deletions

View File

@ -113,6 +113,7 @@ static BOOL StorageImpl_ReadDWordFromBigBlock( StorageImpl* This,
ULONG blockIndex, ULONG offset, DWORD* value);
static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEntry);
static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl * stg, DirRef storageEntry);
static void StorageInternalImpl_Invalidate( StorageInternalImpl *This );
/* OLESTREAM memory structure to use for Get and Put Routines */
@ -579,6 +580,13 @@ static HRESULT WINAPI StorageBaseImpl_OpenStorage(
if ( (storageEntryRef!=DIRENTRY_NULL) &&
(currentEntry.stgType==STGTY_STORAGE) )
{
if (StorageBaseImpl_IsStorageOpen(This, storageEntryRef))
{
/* A single storage cannot be opened a second time. */
res = STG_E_ACCESSDENIED;
goto end;
}
newStorage = StorageInternalImpl_Construct(
This->ancestorStorage,
grfMode,
@ -1875,6 +1883,21 @@ static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEnt
return FALSE;
}
static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl * stg, DirRef storageEntry)
{
StorageInternalImpl *childstg;
LIST_FOR_EACH_ENTRY(childstg, &stg->storageHead, StorageInternalImpl, ParentListEntry)
{
if (childstg->base.storageDirEntry == storageEntry)
{
return TRUE;
}
}
return FALSE;
}
static void StorageBaseImpl_DeleteAll(StorageBaseImpl * stg)
{
struct list *cur, *cur2;

View File

@ -1060,13 +1060,13 @@ static void test_substorage_share(void)
if (r == S_OK)
{
r = IStorage_OpenStorage(stg, stgname, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stg3);
r = IStorage_OpenStorage(stg, stgname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stg3);