https://git.reactos.org/?p=reactos.git;a=commitdiff;h=047a3bf79ab21d84fb480d...
commit 047a3bf79ab21d84fb480d8df99dd087aca97976 Author: Thomas Faber thomas.faber@reactos.org AuthorDate: Wed Apr 17 10:25:52 2019 +0200 Commit: Thomas Faber thomas.faber@reactos.org CommitDate: Sun May 5 10:39:22 2019 +0200
[NTOS:CM] Simplify CmpGetRegistryPath to avoid unnecessary stack buffers. CORE-15882 --- ntoskrnl/config/cmsysini.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c index d672ead8c2..c773f1f569 100644 --- a/ntoskrnl/config/cmsysini.c +++ b/ntoskrnl/config/cmsysini.c @@ -1166,32 +1166,24 @@ CmpCreateRegistryRoot(VOID) return TRUE; }
-static NTSTATUS -CmpGetRegistryPath(OUT PWCHAR ConfigPath) +static PCWSTR +CmpGetRegistryPath(VOID) { - /* Just use default path */ - wcscpy(ConfigPath, L"\SystemRoot"); + PCWSTR ConfigPath;
/* Check if we are booted in setup */ if (!ExpInTextModeSetup) { - /* Add registry path */ -#if 0 - ResultSize = wcslen(ConfigPath); - if (ResultSize && ConfigPath[ResultSize - 1] == L'\') - ConfigPath[ResultSize - 1] = UNICODE_NULL; -#endif - wcscat(ConfigPath, L"\System32\Config\"); + ConfigPath = L"\SystemRoot\System32\Config\"; } else { - wcscat(ConfigPath, L"\"); + ConfigPath = L"\SystemRoot\"; }
DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
- /* Done */ - return STATUS_SUCCESS; + return ConfigPath; }
_Function_class_(KSTART_ROUTINE) @@ -1199,7 +1191,8 @@ VOID NTAPI CmpLoadHiveThread(IN PVOID StartContext) { - WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH]; + WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH]; + PCWSTR ConfigPath; UNICODE_STRING TempName, FileName, RegName; ULONG i, ErrorResponse, WorkerCount, Length; USHORT FileStart; @@ -1222,7 +1215,7 @@ CmpLoadHiveThread(IN PVOID StartContext) RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */ - CmpGetRegistryPath(ConfigPath); + ConfigPath = CmpGetRegistryPath(); RtlInitUnicodeString(&TempName, ConfigPath); RtlAppendUnicodeStringToString(&FileName, &TempName); FileStart = FileName.Length; @@ -1364,7 +1357,8 @@ VOID NTAPI CmpInitializeHiveList(VOID) { - WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH]; + WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH]; + PCWSTR ConfigPath; UNICODE_STRING TempName, FileName, RegName; HANDLE Thread; NTSTATUS Status; @@ -1381,7 +1375,7 @@ CmpInitializeHiveList(VOID) RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */ - CmpGetRegistryPath(ConfigPath); + ConfigPath = CmpGetRegistryPath(); RtlInitUnicodeString(&TempName, ConfigPath); RtlAppendUnicodeStringToString(&FileName, &TempName);