ole32: Fix up permissions when opening streams.

Fix up permissions when opening streams in storage objects when
storage object has been opened in transacted mode.
This commit is contained in:
Dr J A Gow 2006-02-21 17:02:04 +09:00 committed by Alexandre Julliard
parent 54dfdb9b00
commit c74e5a784d
2 changed files with 36 additions and 12 deletions

View File

@ -342,14 +342,17 @@ HRESULT WINAPI StorageBaseImpl_OpenStream(
} }
/* /*
* Check that we're compatible with the parent's storage mode * Check that we're compatible with the parent's storage mode, but
* only if we are not in transacted mode
*/ */
parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags );
if(!(This->ancestorStorage->base.openFlags & STGM_TRANSACTED)) {
if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) )
{ {
res = STG_E_ACCESSDENIED; res = STG_E_ACCESSDENIED;
goto end; goto end;
} }
}
/* /*
* Create a property enumeration to search the properties * Create a property enumeration to search the properties
@ -472,14 +475,17 @@ HRESULT WINAPI StorageBaseImpl_OpenStorage(
} }
/* /*
* Check that we're compatible with the parent's storage mode * Check that we're compatible with the parent's storage mode,
* but only if we are not transacted
*/ */
parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags );
if(!(This->ancestorStorage->base.openFlags & STGM_TRANSACTED)) {
if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) )
{ {
res = STG_E_ACCESSDENIED; res = STG_E_ACCESSDENIED;
goto end; goto end;
} }
}
/* /*
* Initialize the out parameter * Initialize the out parameter
@ -869,10 +875,13 @@ HRESULT WINAPI StorageBaseImpl_CreateStream(
/* /*
* Check that we're compatible with the parent's storage mode * Check that we're compatible with the parent's storage mode
* if not in transacted mode
*/ */
parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags );
if(!(parent_grfMode & STGM_TRANSACTED)) {
if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) )
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
}
/* /*
* Initialize the out parameter * Initialize the out parameter

View File

@ -608,6 +608,21 @@ static void test_storage_refcount(void)
r = IStream_Release(stm); r = IStream_Release(stm);
ok (r == 0, "stream not released\n"); ok (r == 0, "stream not released\n");
/* test for grfMode open issue */
r = StgOpenStorage( filename, NULL, 0x00010020, NULL, 0, &stg);
ok(r==S_OK, "StgOpenStorage failed\n");
if(stg)
{
r = IStorage_OpenStream( stg, stmname, 0, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &stm );
ok(r == S_OK, "OpenStream should succeed\n");
todo_wine {
r = IStorage_Release(stg);
ok(r == 0, "wrong ref count\n");
}
}
DeleteFileW(filename); DeleteFileW(filename);
} }