Dmitry Timoshkov : server: OpenMutex should perform a real access check instead of validating access flags .
Alexandre Julliard
julliard at winehq.org
Mon Mar 12 12:00:00 CDT 2012
Module: wine
Branch: master
Commit: 4b058e6e7979ab724bd609f5886e352cd4323db7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4b058e6e7979ab724bd609f5886e352cd4323db7
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Mon Mar 12 13:40:43 2012 +0800
server: OpenMutex should perform a real access check instead of validating access flags.
This reverts 7b63fa658ac28e715f98876f790cb0de2bc9ac17.
---
dlls/kernel32/tests/sync.c | 20 ++++++++++++++++++++
server/mutex.c | 8 --------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index 3965458..d4f6cf7 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -133,12 +133,23 @@ static void test_mutex(void)
int i;
DWORD failed = 0;
+ SetLastError(0xdeadbeef);
+ hOpened = OpenMutex(0, FALSE, "WineTestMutex");
+ ok(hOpened == NULL, "OpenMutex succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
hCreated = CreateMutex(NULL, FALSE, "WineTestMutex");
ok(hCreated != NULL, "CreateMutex failed with error %d\n", GetLastError());
+ SetLastError(0xdeadbeef);
hOpened = OpenMutex(0, FALSE, "WineTestMutex");
+todo_wine
ok(hOpened == NULL, "OpenMutex succeeded\n");
+todo_wine
+ ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError());
+ SetLastError(0xdeadbeef);
hOpened = OpenMutex(GENERIC_EXECUTE, FALSE, "WineTestMutex");
ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError());
wait_ret = WaitForSingleObject(hOpened, INFINITE);
@@ -151,6 +162,7 @@ static void test_mutex(void)
ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error 0x%08x\n", wait_ret);
}
+ SetLastError(0xdeadbeef);
hOpened = OpenMutex(GENERIC_READ | GENERIC_WRITE, FALSE, "WineTestMutex");
ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError());
wait_ret = WaitForSingleObject(hOpened, INFINITE);
@@ -159,22 +171,30 @@ static void test_mutex(void)
for (i = 0; i < 32; i++)
{
+ SetLastError(0xdeadbeef);
hOpened = OpenMutex(0x1 << i, FALSE, "WineTestMutex");
if(hOpened != NULL)
{
+ SetLastError(0xdeadbeef);
ret = ReleaseMutex(hOpened);
ok(ret, "ReleaseMutex failed with error %d, access %x\n", GetLastError(), 1 << i);
CloseHandle(hOpened);
}
else
{
+ if ((1 << i) == ACCESS_SYSTEM_SECURITY)
+ todo_wine ok(GetLastError() == ERROR_PRIVILEGE_NOT_HELD, "wrong error %u, access %x\n", GetLastError(), 1 << i);
+ else
+ todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u, , access %x\n", GetLastError(), 1 << i);
ReleaseMutex(hCreated);
failed |=0x1 << i;
}
}
+todo_wine
ok( failed == 0x0de0fffe, "open succeeded when it shouldn't: %x\n", failed);
+ SetLastError(0xdeadbeef);
ret = ReleaseMutex(hCreated);
ok(!ret && (GetLastError() == ERROR_NOT_OWNER),
"ReleaseMutex should have failed with ERROR_NOT_OWNER instead of %d\n", GetLastError());
diff --git a/server/mutex.c b/server/mutex.c
index 7c9700d..7514275 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -238,14 +238,6 @@ DECL_HANDLER(open_mutex)
struct directory *root = NULL;
struct mutex *mutex;
- if ((req->access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL |
- MUTEX_ALL_ACCESS | STANDARD_RIGHTS_ALL | MAXIMUM_ALLOWED)) ||
- !req->access)
- {
- set_error(STATUS_INVALID_PARAMETER);
- return;
- }
-
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
More information about the wine-cvs
mailing list