Author: janderwald
Date: Thu Feb 5 11:22:59 2009
New Revision: 39413
URL:
http://svn.reactos.org/svn/reactos?rev=39413&view=rev
Log:
- Improve error checking
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] Thu Feb 5 11:22:59 2009
@@ -601,6 +601,12 @@
DWORD dwLength;
int len;
LPSTR lpStr;
+
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
if (lpServiceName)
{
@@ -1299,6 +1305,12 @@
TRACE("%p %s %p %p\n", hSCManager,
debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
if (!lpDisplayName)
*lpcchBuffer = 0;
@@ -1385,6 +1397,19 @@
DWORD dwError;
TRACE("GetServiceKeyNameA() called\n");
+
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!lpDisplayName)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ *lpcchBuffer = 1;
+ return FALSE;
+ }
if (!lpServiceName)
*lpcchBuffer = 0;
@@ -1639,6 +1664,12 @@
TRACE("OpenServiceA(%p, %s, %lx)\n",
hSCManager, lpServiceName, dwDesiredAccess);
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+
RpcTryExcept
{
/* Call to services.exe using RPC */