From 17231794303c30bb28c6bee1f9b3fe4303c6c6b6 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sat, 10 Sep 2022 17:14:19 +0100 Subject: [PATCH] dll: FspFsctlStartService: fix bug in non-SxS mode --- src/dll/fsctl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dll/fsctl.c b/src/dll/fsctl.c index 2a4d3542..3ab8b0e0 100644 --- a/src/dll/fsctl.c +++ b/src/dll/fsctl.c @@ -524,10 +524,9 @@ exit: static VOID FspFsctlStartService_EnumFn(PVOID Context, PWSTR ServiceName, BOOLEAN Running) { - PWSTR *PDriverName = Context; - if (0 == *PDriverName || - 0 > invariant_wcscmp(*PDriverName, ServiceName)) - *PDriverName = ServiceName; + PWSTR DriverName = Context; + if (0 > invariant_wcscmp(DriverName, ServiceName)) + lstrcpyW(DriverName, ServiceName); } FSP_API NTSTATUS FspFsctlStartService(VOID) @@ -549,17 +548,18 @@ FSP_API NTSTATUS FspFsctlStartService(VOID) /* non-SxS mode */ NTSTATUS Result; - PWSTR DriverName = 0; + WCHAR DriverName[256]; Result = FspFsctlStartServiceByName(L"" FSP_FSCTL_DRIVER_NAME); - if (NT_SUCCESS(Result)) + if (NT_SUCCESS(Result) || STATUS_NO_SUCH_DEVICE != Result) return Result; /* DO NOT CLOBBER Result. We will return it if our best effort below fails. */ - FspFsctlEnumServices(FspFsctlStartService_EnumFn, &DriverName); + DriverName[0] = L'\0'; + FspFsctlEnumServices(FspFsctlStartService_EnumFn, DriverName); - if (0 == DriverName || !NT_SUCCESS(FspFsctlStartServiceByName(DriverName))) + if (L'\0' == DriverName[0] || !NT_SUCCESS(FspFsctlStartServiceByName(DriverName))) return Result; return STATUS_SUCCESS;