Author: ekohl
Date: Sun Jan 31 23:22:50 2010
New Revision: 45366
URL:
http://svn.reactos.org/svn/reactos?rev=45366&view=rev
Log:
GetServiceDisplayNameA/W and GetServiceKeyNameA/W must return an empty String if the given
Buffer is too small. This fixes 6 tests.
Modified:
trunk/reactos/dll/win32/advapi32/service/scm.c
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Sun Jan 31 23:22:50 2010
@@ -1289,6 +1289,8 @@
LPDWORD lpcchBuffer)
{
DWORD dwError;
+ LPSTR lpNameBuffer;
+ CHAR szEmptyName[] = "";
TRACE("GetServiceDisplayNameA() called\n");
TRACE("%p %s %p %p\n", hSCManager,
@@ -1300,14 +1302,21 @@
return FALSE;
}
- if (!lpDisplayName)
- *lpcchBuffer = 0;
+ if (!lpDisplayName || *lpcchBuffer < sizeof(CHAR))
+ {
+ lpNameBuffer = szEmptyName;
+ *lpcchBuffer = sizeof(CHAR);
+ }
+ else
+ {
+ lpNameBuffer = lpDisplayName;
+ }
RpcTryExcept
{
dwError = RGetServiceDisplayNameA((SC_RPC_HANDLE)hSCManager,
lpServiceName,
- lpDisplayName,
+ lpNameBuffer,
lpcchBuffer);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@@ -1315,8 +1324,6 @@
/* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for
ERROR_SERVICE_DOES_NOT_EXIST */
dwError = ScmRpcStatusToWinError(RpcExceptionCode());
}
-
-
RpcEndExcept;
if (dwError != ERROR_SUCCESS)
@@ -1342,6 +1349,8 @@
LPDWORD lpcchBuffer)
{
DWORD dwError;
+ LPWSTR lpNameBuffer;
+ WCHAR szEmptyName[] = L"";
TRACE("GetServiceDisplayNameW() called\n");
@@ -1351,14 +1360,21 @@
return FALSE;
}
- if (!lpDisplayName)
- *lpcchBuffer = 0;
+ if (!lpDisplayName || *lpcchBuffer < sizeof(WCHAR))
+ {
+ lpNameBuffer = szEmptyName;
+ *lpcchBuffer = sizeof(WCHAR);
+ }
+ else
+ {
+ lpNameBuffer = lpDisplayName;
+ }
RpcTryExcept
{
dwError = RGetServiceDisplayNameW((SC_RPC_HANDLE)hSCManager,
lpServiceName,
- lpDisplayName,
+ lpNameBuffer,
lpcchBuffer);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@@ -1390,6 +1406,8 @@
LPDWORD lpcchBuffer)
{
DWORD dwError;
+ LPSTR lpNameBuffer;
+ CHAR szEmptyName[] = "";
TRACE("GetServiceKeyNameA() called\n");
@@ -1399,23 +1417,21 @@
return FALSE;
}
- if (!lpDisplayName)
- {
- SetLastError(ERROR_INVALID_ADDRESS);
-
- if (!lpServiceName)
- *lpcchBuffer = 1;
- return FALSE;
- }
-
- if (!lpServiceName)
- *lpcchBuffer = 0;
+ if (!lpServiceName || *lpcchBuffer < sizeof(CHAR))
+ {
+ lpNameBuffer = szEmptyName;
+ *lpcchBuffer = sizeof(CHAR);
+ }
+ else
+ {
+ lpNameBuffer = lpServiceName;
+ }
RpcTryExcept
{
dwError = RGetServiceKeyNameA((SC_RPC_HANDLE)hSCManager,
lpDisplayName,
- lpServiceName,
+ lpNameBuffer,
lpcchBuffer);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@@ -1447,6 +1463,8 @@
LPDWORD lpcchBuffer)
{
DWORD dwError;
+ LPWSTR lpNameBuffer;
+ WCHAR szEmptyName[] = L"";
TRACE("GetServiceKeyNameW() called\n");
@@ -1456,23 +1474,21 @@
return FALSE;
}
- if (!lpDisplayName)
- {
- SetLastError(ERROR_INVALID_ADDRESS);
-
- if (!lpServiceName)
- *lpcchBuffer = 1;
- return FALSE;
- }
-
- if (!lpServiceName)
- *lpcchBuffer = 0;
+ if (!lpServiceName || *lpcchBuffer < sizeof(WCHAR))
+ {
+ lpNameBuffer = szEmptyName;
+ *lpcchBuffer = sizeof(WCHAR);
+ }
+ else
+ {
+ lpNameBuffer = lpServiceName;
+ }
RpcTryExcept
{
dwError = RGetServiceKeyNameW((SC_RPC_HANDLE)hSCManager,
lpDisplayName,
- lpServiceName,
+ lpNameBuffer,
lpcchBuffer);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)