Author: ekohl Date: Fri Aug 29 05:34:23 2008 New Revision: 35750
URL: http://svn.reactos.org/svn/reactos?rev=35750&view=rev Log: - ScmCreateManagerHandle: Fail on invalid database names. - ROpenServiceW: Fail if lpServiceName is NULL. - ROpenServiceA: Don't pass an empty string to ROpenServiceW if lpServiceName is NULL. Use NULL instead.
This patch is based on bug report #3669 by bugboy martinmnet@hotmail.com.
Modified: trunk/reactos/base/system/services/rpcserver.c
Modified: trunk/reactos/base/system/services/rpcserver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcser... ============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Fri Aug 29 05:34:23 2008 @@ -151,6 +151,17 @@
if (lpDatabaseName == NULL) lpDatabaseName = SERVICES_ACTIVE_DATABASEW; + + if (wcsicmp(lpDatabaseName,SERVICES_FAILED_DATABASEW)==0) + { + DPRINT1("Database %S, does not exist\n",lpDatabaseName); + return ERROR_DATABASE_DOES_NOT_EXIST; + } + else if (wcsicmp(lpDatabaseName, SERVICES_ACTIVE_DATABASEW) != 0) + { + DPRINT1("Invalid Database name %S.\n",lpDatabaseName); + return ERROR_INVALID_NAME; + }
Ptr = (MANAGER_HANDLE*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -1936,6 +1947,9 @@ if (!lpServiceHandle) return ERROR_INVALID_PARAMETER;
+ if (!lpServiceName) + return ERROR_INVALID_ADDRESS; + hManager = (PMANAGER_HANDLE)hSCManager; if (!hManager || hManager->Handle.Tag != MANAGER_TAG) { @@ -2489,8 +2503,9 @@
DPRINT("ROpenServiceA() called\n");
- RtlCreateUnicodeStringFromAsciiz(&ServiceName, - lpServiceName); + if (lpServiceName) + RtlCreateUnicodeStringFromAsciiz(&ServiceName, + lpServiceName);
dwError = ROpenServiceW(BindingHandle, hSCManager, @@ -2498,7 +2513,8 @@ dwDesiredAccess, lpServiceHandle);
- RtlFreeUnicodeString(&ServiceName); + if (lpServiceName) + RtlFreeUnicodeString(&ServiceName);
return dwError; }