[ros-diffs] [janderwald] 39419: - Add more error checks which reduce winetest errors

janderwald at svn.reactos.org janderwald at svn.reactos.org
Thu Feb 5 20:13:37 CET 2009


Author: janderwald
Date: Thu Feb  5 13:13:35 2009
New Revision: 39419

URL: http://svn.reactos.org/svn/reactos?rev=39419&view=rev
Log:
- Add more error checks which reduce winetest errors

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/scm.c?rev=39419&r1=39418&r2=39419&view=diff
==============================================================================
--- 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 13:13:35 2009
@@ -1025,6 +1025,48 @@
 
     TRACE("EnumServicesStatusA() called\n");
 
+    if (!hSCManager)
+    {
+        SetLastError(ERROR_INVALID_HANDLE);
+        return FALSE;
+    }
+
+    if (dwServiceType != SERVICE_DRIVER && dwServiceType != SERVICE_WIN32)
+    {
+        if (pcbBytesNeeded && lpServicesReturned)
+        {
+            *pcbBytesNeeded = 0;
+            *lpServicesReturned = 0;
+        }
+
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (dwServiceState != SERVICE_ACTIVE && dwServiceState != SERVICE_INACTIVE && dwServiceState != SERVICE_STATE_ALL)
+    {
+            if (pcbBytesNeeded)
+                *pcbBytesNeeded = 0;
+
+            if (lpServicesReturned)
+                *lpServicesReturned = 0;
+
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (!pcbBytesNeeded || !lpServicesReturned || !lpResumeHandle)
+    {
+        SetLastError(ERROR_INVALID_ADDRESS);
+        return FALSE;
+    }
+
+    if (!lpServices && cbBufSize != 0)
+    {
+        SetLastError(ERROR_INVALID_ADDRESS);
+        return FALSE;
+    }
+
     RpcTryExcept
     {
         dwError = REnumServicesStatusA((SC_RPC_HANDLE)hSCManager,
@@ -1407,7 +1449,9 @@
     if (!lpDisplayName)
     {
         SetLastError(ERROR_INVALID_ADDRESS);
-        *lpcchBuffer = 1;
+
+        if (!lpServiceName)
+            *lpcchBuffer = 1;
         return FALSE;
     }
 
@@ -2295,6 +2339,12 @@
     TRACE("QueryServiceStatus(%p, %p)\n",
            hService, lpServiceStatus);
 
+    if (!hService)
+    {
+        SetLastError(ERROR_INVALID_HANDLE);
+        return FALSE;
+    }
+
     RpcTryExcept
     {
         /* Call to services.exe using RPC */
@@ -2333,6 +2383,12 @@
     DWORD dwError;
 
     TRACE("QueryServiceStatusEx() called\n");
+
+    if (InfoLevel != SC_STATUS_PROCESS_INFO)
+    {
+        SetLastError(ERROR_INVALID_LEVEL);
+        return FALSE;
+    }
 
     RpcTryExcept
     {



More information about the Ros-diffs mailing list