Skip to content

Commit

Permalink
[ADVAPI32] StartServiceCtrlDispatcherA/W(): Check the names of servic…
Browse files Browse the repository at this point in the history
…es when counting them. Fail also if none were found.
  • Loading branch information
HBelusca committed Sep 28, 2024
1 parent d14b6b8 commit 6250558
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions dll/win32/advapi32/service/sctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,14 +1061,23 @@ StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA *lpServiceStartTable)
return FALSE;
}

/* Count the number of active services. They must
* have a "valid" name and service procedure. */
i = 0;
while (lpServiceStartTable[i].lpServiceProc != NULL)
while (lpServiceStartTable[i].lpServiceName != NULL &&
lpServiceStartTable[i].lpServiceProc != NULL)
{
i++;
++i;
}

dwActiveServiceCount = i;

/* If no active services were found, fail the call */
if (!dwActiveServiceCount)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}

/* Allocate the service table */
lpActiveServices = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
Expand Down Expand Up @@ -1151,14 +1160,23 @@ StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
return FALSE;
}

/* Count the number of active services. They must
* have a "valid" name and service procedure. */
i = 0;
while (lpServiceStartTable[i].lpServiceProc != NULL)
while (lpServiceStartTable[i].lpServiceName != NULL &&
lpServiceStartTable[i].lpServiceProc != NULL)
{
i++;
++i;
}

dwActiveServiceCount = i;

/* If no active services were found, fail the call */
if (!dwActiveServiceCount)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}

/* Allocate the service table */
lpActiveServices = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
Expand Down

0 comments on commit 6250558

Please sign in to comment.