Robert Shearman : ole32: Fix access right check for opening and creating streams and storages.

Alexandre Julliard julliard at wine.codeweavers.com
Fri May 5 15:24:13 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: b2207d83ad9c42c24a7dfec66fbd5bc76f438db1
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=b2207d83ad9c42c24a7dfec66fbd5bc76f438db1

Author: Robert Shearman <rob at codeweavers.com>
Date:   Wed May  3 14:48:58 2006 +0100

ole32: Fix access right check for opening and creating streams and storages.

Check the access mode for opening and creating streams and storages
doesn't exceed the access rights the current storage was opened with,
not the parent storage.

---

 dlls/ole32/storage32.c       |   18 +++++-------------
 dlls/ole32/tests/storage32.c |    4 ++--
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index a3f21d5..6369410 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -302,7 +302,6 @@ HRESULT WINAPI StorageBaseImpl_OpenStrea
   StgProperty       currentProperty;
   ULONG             foundPropertyIndex;
   HRESULT           res = STG_E_UNKNOWN;
-  DWORD             parent_grfMode;
 
   TRACE("(%p, %s, %p, %lx, %ld, %p)\n",
 	iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
@@ -345,9 +344,8 @@ HRESULT WINAPI StorageBaseImpl_OpenStrea
    * 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 );
   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( This->openFlags ) )
     {
       res = STG_E_ACCESSDENIED;
       goto end;
@@ -438,7 +436,6 @@ HRESULT WINAPI StorageBaseImpl_OpenStora
   StgProperty            currentProperty;
   ULONG                  foundPropertyIndex;
   HRESULT                res = STG_E_UNKNOWN;
-  DWORD                  parent_grfMode;
 
   TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n",
 	iface, debugstr_w(pwcsName), pstgPriority,
@@ -484,9 +481,8 @@ HRESULT WINAPI StorageBaseImpl_OpenStora
    * 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 );
   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( This->openFlags ) )
     {
       res = STG_E_ACCESSDENIED;
       goto end;
@@ -845,7 +841,6 @@ HRESULT WINAPI StorageBaseImpl_CreateStr
   StgStreamImpl*    newStream;
   StgProperty       currentProperty, newStreamProperty;
   ULONG             foundPropertyIndex, newPropertyIndex;
-  DWORD             parent_grfMode;
 
   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
 	iface, debugstr_w(pwcsName), grfMode,
@@ -883,9 +878,8 @@ HRESULT WINAPI StorageBaseImpl_CreateStr
    * 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 );
-  if(!(parent_grfMode & STGM_TRANSACTED)) {
-    if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) )
+  if(!(This->ancestorStorage->base.openFlags & STGM_TRANSACTED)) {
+    if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
       return STG_E_ACCESSDENIED;
   }
 
@@ -1062,7 +1056,6 @@ HRESULT WINAPI StorageImpl_CreateStorage
   ULONG            foundPropertyIndex;
   ULONG            newPropertyIndex;
   HRESULT          hr;
-  DWORD            parent_grfMode;
 
   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
 	iface, debugstr_w(pwcsName), grfMode,
@@ -1095,8 +1088,7 @@ HRESULT WINAPI StorageImpl_CreateStorage
   /*
    * Check that we're compatible with the parent's storage mode
    */
-  parent_grfMode = STGM_ACCESS_MODE( This->base.ancestorStorage->base.openFlags );
-  if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) )
+  if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->base.openFlags ) )
   {
     WARN("access denied\n");
     return STG_E_ACCESSDENIED;
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 4236fd1..0a70ad5 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -684,18 +684,18 @@ static void test_storage_refcount(void)
         r = IStorage_CreateStorage( stg, stgname, STGM_SHARE_EXCLUSIVE, 0, 0, &stg2 );
         ok(r == S_OK, "CreateStorage should have succeeded instead of returning 0x%08lx\n", r);
 
-        todo_wine {
         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);
 
         r = IStorage_Release(stg);
         ok(r == 0, "wrong ref count\n");
-        }
     }
 
     DeleteFileW(filename);




More information about the wine-cvs mailing list