From 52d17f5d446dfb40d4418be17a1ed0a20ed9c2e9 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 2 Dec 2009 11:28:09 -0600 Subject: [PATCH 1/5] ole32: Forbid substorages of simple mode storages. --- dlls/ole32/storage32.c | 11 +++++++++++ dlls/ole32/tests/storage32.c | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 089206d..3991b9e 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -530,6 +530,12 @@ static HRESULT WINAPI StorageBaseImpl_OpenStorage( goto end; } + if (This->openFlags & STGM_SIMPLE) + { + res = STG_E_INVALIDFUNCTION; + goto end; + } + /* as documented */ if (snbExclude != NULL) { @@ -1022,6 +1028,11 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage( if (ppstg == 0) return STG_E_INVALIDPOINTER; + if (This->openFlags & STGM_SIMPLE) + { + return STG_E_INVALIDFUNCTION; + } + if (pwcsName == 0) return STG_E_INVALIDNAME; diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 53811db..6e222c7 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -1774,9 +1774,10 @@ static void test_simple(void) { /* Tests for STGM_SIMPLE mode */ - IStorage *stg; + IStorage *stg, *stg2; HRESULT r; IStream *stm; + static const WCHAR stgname[] = { 'S','t','g',0 }; static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 }; static const WCHAR stmname2[] = { 'S','m','a','l','l',0 }; LARGE_INTEGER pos; @@ -1789,6 +1790,10 @@ static void test_simple(void) r = StgCreateDocfile( filename, STGM_SIMPLE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg); ok(r == S_OK, "got %08x\n", r); + r = IStorage_CreateStorage(stg, stgname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stg2); + ok(r == STG_E_INVALIDFUNCTION, "got %08x\n", r); + if (SUCCEEDED(r)) IStorage_Release(stg2); + r = IStorage_CreateStream(stg, stmname, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm); ok(r == STG_E_INVALIDFLAG, "got %08x\n", r); r = IStorage_CreateStream(stg, stmname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm); @@ -1853,6 +1858,10 @@ static void test_simple(void) } ok(r == S_OK, "got %08x\n", r); + r = IStorage_OpenStorage(stg, stgname, NULL, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, NULL, 0, &stg2); + ok(r == STG_E_INVALIDFUNCTION, "got %08x\n", r); + if (SUCCEEDED(r)) IStorage_Release(stg2); + r = IStorage_OpenStream(stg, stmname, NULL, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stm); ok(r == S_OK, "got %08x\n", r); -- 1.6.3.3