diff --git a/ChangeLog b/ChangeLog index 898d02935..497c900b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-01-15 Richard Frith-Macdonald + + * Source/win32/NSMessagePortNameServerWin32.m: + * Source/win32/NSMessagePortWin32.m: + Add hack to cope with bug reading registry ... better solution welcome + if anyone knows one. + Add security attributes to message port stuff ... should only let + current user on current machine access message ports I hope. + 2006-01-12 Richard Frith-Macdonald * Source/NSPathUtilities.m: Fix possible read off end of buffer diff --git a/Source/win32/NSMessagePortNameServerWin32.m b/Source/win32/NSMessagePortNameServerWin32.m index d21e873fb..e5c020a79 100644 --- a/Source/win32/NSMessagePortNameServerWin32.m +++ b/Source/win32/NSMessagePortNameServerWin32.m @@ -50,6 +50,8 @@ static NSMapTable portToNamesMap; static NSString *registry; static HKEY key; +static SECURITY_ATTRIBUTES security; + @interface NSMessagePortNameServer (private) + (NSString *) _query: (NSString *)name; + (NSString *) _translate: (NSString *)name; @@ -97,6 +99,10 @@ static void clean_up_names(void) NSObjectMapValueCallBacks, 0); atexit(clean_up_names); + security.nLength = sizeof(SECURITY_ATTRIBUTES); + security.lpSecurityDescriptor = 0; // Default + security.bInheritHandle = TRUE; + registry = @"Software\\GNUstepNSMessagePort"; rc = RegCreateKeyExW( HKEY_CURRENT_USER, @@ -106,7 +112,7 @@ static void clean_up_names(void) REG_OPTION_VOLATILE, STANDARD_RIGHTS_WRITE|STANDARD_RIGHTS_READ|KEY_SET_VALUE |KEY_QUERY_VALUE|KEY_NOTIFY, - NULL, + &security, &key, NULL); if (rc == ERROR_SUCCESS) @@ -203,7 +209,7 @@ OutputDebugStringW(L""); UNISTR(p), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, - (LPSECURITY_ATTRIBUTES)0, + &security, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0); diff --git a/Source/win32/NSMessagePortWin32.m b/Source/win32/NSMessagePortWin32.m index 5b8d486c6..aada0bdda 100644 --- a/Source/win32/NSMessagePortWin32.m +++ b/Source/win32/NSMessagePortWin32.m @@ -127,6 +127,8 @@ typedef struct { @implementation NSMessagePort +static SECURITY_ATTRIBUTES security; + static NSRecursiveLock *messagePortLock = nil; /* @@ -152,7 +154,7 @@ static Class messagePortClass = 0; UNISTR(path), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, - (LPSECURITY_ATTRIBUTES)0, + &security, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, (HANDLE)0); @@ -184,6 +186,10 @@ static Class messagePortClass = 0; NSNonOwnedPointerMapValueCallBacks, 0); messagePortLock = [GSLazyRecursiveLock new]; + + security.nLength = sizeof(SECURITY_ATTRIBUTES); + security.lpSecurityDescriptor = 0; // Default + security.bInheritHandle = TRUE; } } @@ -322,7 +328,7 @@ static Class messagePortClass = 0; UNISTR(path), 0, /* No max message size. */ MAILSLOT_WAIT_FOREVER, /* No read/write timeout. */ - (LPSECURITY_ATTRIBUTES)0); + &security); if (this->rHandle == INVALID_HANDLE_VALUE) {