From ead9dcbd3159b929c8d6928690b4af3d6795447a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 6 Feb 2009 08:51:51 +0000 Subject: [PATCH] add some more error checking svn path=/trunk/; revision=39434 --- reactos/dll/win32/advapi32/service/scm.c | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/reactos/dll/win32/advapi32/service/scm.c b/reactos/dll/win32/advapi32/service/scm.c index df95d15f9cc..1f643b31348 100644 --- a/reactos/dll/win32/advapi32/service/scm.c +++ b/reactos/dll/win32/advapi32/service/scm.c @@ -770,6 +770,12 @@ CreateServiceW(SC_HANDLE hSCManager, TRACE("%p %S %S\n", hSCManager, lpServiceName, lpDisplayName); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + /* Calculate the Dependencies length*/ if (lpDependencies != NULL) { @@ -1132,6 +1138,12 @@ EnumServicesStatusW(SC_HANDLE hSCManager, TRACE("EnumServicesStatusW() called\n"); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + RpcTryExcept { dwError = REnumServicesStatusW((SC_RPC_HANDLE)hSCManager, @@ -1398,6 +1410,12 @@ GetServiceDisplayNameW(SC_HANDLE hSCManager, TRACE("GetServiceDisplayNameW() called\n"); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!lpDisplayName) *lpcchBuffer = 0; @@ -1497,7 +1515,22 @@ GetServiceKeyNameW(SC_HANDLE hSCManager, TRACE("GetServiceKeyNameW() called\n"); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!lpDisplayName) + { + SetLastError(ERROR_INVALID_ADDRESS); + + if (!lpServiceName) + *lpcchBuffer = 1; + return FALSE; + } + + if (!lpServiceName) *lpcchBuffer = 0; RpcTryExcept @@ -1757,6 +1790,12 @@ OpenServiceW(SC_HANDLE hSCManager, TRACE("OpenServiceW(%p, %S, %lx)\n", hSCManager, lpServiceName, dwDesiredAccess); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + RpcTryExcept { /* Call to services.exe using RPC */