From 693da8c47152187d6ba210a0f63168ad95040187 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 3 May 2006 14:49:17 +0100 Subject: [PATCH] ole32: Check that the storage was opened with write access before creating a new stream or sub-storage. --- dlls/ole32/storage32.c | 10 ++++++++++ dlls/ole32/tests/storage32.c | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 79362b5765e..18f248cbfd8 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -914,6 +914,11 @@ HRESULT WINAPI StorageBaseImpl_CreateStream( else return STG_E_FILEALREADYEXISTS; } + else if (STGM_ACCESS_MODE(This->openFlags) == STGM_READ) + { + WARN("read-only storage\n"); + return STG_E_ACCESSDENIED; + } /* * memset the empty property @@ -1120,6 +1125,11 @@ HRESULT WINAPI StorageImpl_CreateStorage( return STG_E_FILEALREADYEXISTS; } } + else if (STGM_ACCESS_MODE(This->base.openFlags) == STGM_READ) + { + WARN("read-only storage\n"); + return STG_E_ACCESSDENIED; + } /* * memset the empty property diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 37492edc9d8..19361505a12 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -719,10 +719,8 @@ static void test_storage_refcount(void) r = IStorage_CreateStorage( stg2, stgname2, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, 0, &stg3 ); ok(r == STG_E_ACCESSDENIED, "CreateStorage should have returned STG_E_ACCESSDENIED instead of 0x%08lx\n", r); - todo_wine { r = IStorage_CreateStream( stg2, stmname2, STGM_CREATE|STGM_SHARE_EXCLUSIVE, 0, 0, &stm ); ok(r == STG_E_ACCESSDENIED, "CreateStream should have returned STG_E_ACCESSDENIED instead of 0x%08lx\n", r); - } IStorage_Release(stg2);