Alexandre Julliard : kernel32: Semaphore names are case sensitive.

Alexandre Julliard julliard at winehq.org
Wed May 21 16:32:06 CDT 2008


Module: wine
Branch: master
Commit: 116297d0c17694a2a7b7f7060f80e50f51d8ae87
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=116297d0c17694a2a7b7f7060f80e50f51d8ae87

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed May 21 20:43:43 2008 +0200

kernel32: Semaphore names are case sensitive.

---

 dlls/kernel32/sync.c       |    5 ++---
 dlls/kernel32/tests/sync.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index eb2fcc5..e317bf7 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -794,8 +794,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
     attr.Length                   = sizeof(attr);
     attr.RootDirectory            = 0;
     attr.ObjectName               = NULL;
-    attr.Attributes               = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
-                                    ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
+    attr.Attributes               = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
     attr.SecurityDescriptor       = sa ? sa->lpSecurityDescriptor : NULL;
     attr.SecurityQualityOfService = NULL;
     if (name)
@@ -847,7 +846,7 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
     attr.Length                   = sizeof(attr);
     attr.RootDirectory            = 0;
     attr.ObjectName               = NULL;
-    attr.Attributes               = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
+    attr.Attributes               = inherit ? OBJ_INHERIT : 0;
     attr.SecurityDescriptor       = NULL;
     attr.SecurityQualityOfService = NULL;
     if (name)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index e3de911..6402457 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -336,6 +336,42 @@ static void test_event(void)
     CloseHandle( handle );
 }
 
+static void test_semaphore(void)
+{
+    HANDLE handle, handle2;
+
+    /* test case sensitivity */
+
+    SetLastError(0xdeadbeef);
+    handle = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": Test Semaphore");
+    ok(handle != NULL, "CreateSemaphore failed with error %u\n", GetLastError());
+    ok(GetLastError() == 0, "wrong error %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    handle2 = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": Test Semaphore");
+    ok( handle2 != NULL, "CreateSemaphore failed with error %d\n", GetLastError());
+    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    CloseHandle( handle2 );
+
+    SetLastError(0xdeadbeef);
+    handle2 = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": TEST SEMAPHORE");
+    ok( handle2 != NULL, "CreateSemaphore failed with error %d\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    CloseHandle( handle2 );
+
+    SetLastError(0xdeadbeef);
+    handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, __FILE__ ": Test Semaphore");
+    ok( handle2 != NULL, "OpenSemaphore failed with error %d\n", GetLastError());
+    CloseHandle( handle2 );
+
+    SetLastError(0xdeadbeef);
+    handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, __FILE__ ": TEST SEMAPHORE");
+    ok( !handle2, "OpenSemaphore succeeded\n");
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+
+    CloseHandle( handle );
+}
+
 static HANDLE sem = 0;
 
 static void CALLBACK iocp_callback(DWORD dwErrorCode, DWORD dwNumberOfBytesTransferred, LPOVERLAPPED lpOverlapped)
@@ -451,5 +487,6 @@ START_TEST(sync)
     test_mutex();
     test_slist();
     test_event();
+    test_semaphore();
     test_iocp_callback();
 }




More information about the wine-cvs mailing list