Author: ekohl
Date: Wed Nov 9 23:18:37 2011
New Revision: 54342
URL:
http://svn.reactos.org/svn/reactos?rev=54342&view=rev
Log:
[SERVICES]
Improve the parameter checks in RCreateServiceW.
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/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Wed Nov 9 23:18:37 2011
@@ -1999,26 +1999,39 @@
return ERROR_INVALID_PARAMETER;
}
- if ((dwServiceType & SERVICE_KERNEL_DRIVER) &&
- (dwServiceType & SERVICE_FILE_SYSTEM_DRIVER))
- {
+ /* Check for invalid service type value */
+ if ((dwServiceType != SERVICE_KERNEL_DRIVER) &&
+ (dwServiceType != SERVICE_FILE_SYSTEM_DRIVER) &&
+ ((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) != SERVICE_WIN32_OWN_PROCESS)
&&
+ ((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) !=
SERVICE_WIN32_SHARE_PROCESS))
+ return ERROR_INVALID_PARAMETER;
+
+ /* Check for invalid start type value */
+ if ((dwStartType != SERVICE_BOOT_START) &&
+ (dwStartType != SERVICE_SYSTEM_START) &&
+ (dwStartType != SERVICE_AUTO_START) &&
+ (dwStartType != SERVICE_DEMAND_START) &&
+ (dwStartType != SERVICE_DISABLED))
return ERROR_INVALID_PARAMETER;
- }
+
+ /* Only drivers can be boot start or system start services */
+ if ((dwStartType == SERVICE_BOOT_START) ||
+ (dwStartType == SERVICE_SYSTEM_START))
+ {
+ if ((dwServiceType != SERVICE_KERNEL_DRIVER) &&
+ (dwServiceType != SERVICE_FILE_SYSTEM_DRIVER))
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* Check for invalid error control value */
+ if ((dwErrorControl != SERVICE_ERROR_IGNORE) &&
+ (dwErrorControl != SERVICE_ERROR_NORMAL) &&
+ (dwErrorControl != SERVICE_ERROR_SEVERE) &&
+ (dwErrorControl != SERVICE_ERROR_CRITICAL))
+ return ERROR_INVALID_PARAMETER;
if ((dwServiceType == (SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS))
&&
(lpServiceStartName))
- {
- return ERROR_INVALID_PARAMETER;
- }
-
- if ((dwServiceType > SERVICE_WIN32_SHARE_PROCESS) &&
- (dwServiceType != (SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS))
&&
- (dwServiceType != (SERVICE_WIN32_SHARE_PROCESS | SERVICE_INTERACTIVE_PROCESS)))
- {
- return ERROR_INVALID_PARAMETER;
- }
-
- if (dwStartType > SERVICE_DISABLED)
{
return ERROR_INVALID_PARAMETER;
}