https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6bf64780e4b798f6f864c…
commit 6bf64780e4b798f6f864c57a60ebc0e916d1f55e
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Thu Jun 17 15:59:48 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Mon Jun 28 10:20:57 2021 +0200
[NET] Properly check return value of EnumServicesStatusW on first call
---
base/applications/network/net/cmdStart.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/base/applications/network/net/cmdStart.c
b/base/applications/network/net/cmdStart.c
index 50029b129d9..1ae2d09b8c2 100644
--- a/base/applications/network/net/cmdStart.c
+++ b/base/applications/network/net/cmdStart.c
@@ -23,6 +23,7 @@ EnumerateRunningServices(VOID)
INT i;
INT nError = 0;
DWORD dwError = ERROR_SUCCESS;
+ BOOL ret;
hManager = OpenSCManagerW(NULL,
SERVICES_ACTIVE_DATABASE,
@@ -34,14 +35,22 @@ EnumerateRunningServices(VOID)
goto done;
}
- EnumServicesStatusW(hManager,
- SERVICE_WIN32,
- SERVICE_ACTIVE,
- NULL,
- 0,
- &dwBufferSize,
- &dwServiceCount,
- &dwResumeHandle);
+ ret = EnumServicesStatusW(hManager,
+ SERVICE_WIN32,
+ SERVICE_ACTIVE,
+ NULL,
+ 0,
+ &dwBufferSize,
+ &dwServiceCount,
+ &dwResumeHandle);
+ if (ret)
+ {
+ /* Nothing to enumerate ?! */
+ goto done;
+ }
+ dwError = GetLastError();
+ if (dwError != ERROR_INSUFFICIENT_BUFFER)
+ goto done;
if (dwBufferSize != 0)
{