https://git.reactos.org/?p=reactos.git;a=commitdiff;h=60346a5732726bc52002d…
commit 60346a5732726bc52002da36d8d7f25845bec3c3
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sun Mar 31 09:18:16 2019 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun May 17 21:30:08 2020 +0200
[NTOS] Prohibit use of MAX_PATH in the kernel. Use MAX_WIN32_PATH if you really mean
it. CORE-15882
---
ntoskrnl/ex/init.c | 10 +++++-----
ntoskrnl/include/ntoskrnl.h | 5 +++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c
index 39869a5b061..c09918e2533 100644
--- a/ntoskrnl/ex/init.c
+++ b/ntoskrnl/ex/init.c
@@ -401,7 +401,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
ProcessInformation = &InitBuffer->ProcessInfo;
/* Allocate memory for the process parameters */
- Size = sizeof(*ProcessParams) + ((MAX_PATH * 6) * sizeof(WCHAR));
+ Size = sizeof(*ProcessParams) + ((MAX_WIN32_PATH * 6) * sizeof(WCHAR));
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
(PVOID*)&ProcessParams,
0,
@@ -456,7 +456,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
/* Make a buffer for the DOS path */
p = (PWSTR)(ProcessParams + 1);
ProcessParams->CurrentDirectory.DosPath.Buffer = p;
- ProcessParams->CurrentDirectory.DosPath.MaximumLength = MAX_PATH *
+ ProcessParams->CurrentDirectory.DosPath.MaximumLength = MAX_WIN32_PATH *
sizeof(WCHAR);
/* Copy the DOS path */
@@ -467,7 +467,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
ProcessParams->CurrentDirectory.DosPath.MaximumLength);
ProcessParams->DllPath.Buffer = p;
- ProcessParams->DllPath.MaximumLength = MAX_PATH * sizeof(WCHAR);
+ ProcessParams->DllPath.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
/* Copy the DLL path and append the system32 directory */
RtlCopyUnicodeString(&ProcessParams->DllPath,
@@ -478,7 +478,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
ProcessParams->DllPath.MaximumLength);
ProcessParams->ImagePathName.Buffer = p;
- ProcessParams->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR);
+ ProcessParams->ImagePathName.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
/* Make sure the buffer is a valid string which within the given length */
if ((NtInitialUserProcessBufferType != REG_SZ) ||
@@ -516,7 +516,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
ProcessParams->ImagePathName.MaximumLength);
ProcessParams->CommandLine.Buffer = p;
- ProcessParams->CommandLine.MaximumLength = MAX_PATH * sizeof(WCHAR);
+ ProcessParams->CommandLine.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
/* Add the image name to the command line */
RtlAppendUnicodeToString(&ProcessParams->CommandLine,
diff --git a/ntoskrnl/include/ntoskrnl.h b/ntoskrnl/include/ntoskrnl.h
index c03dc5dff1d..85970d59892 100644
--- a/ntoskrnl/include/ntoskrnl.h
+++ b/ntoskrnl/include/ntoskrnl.h
@@ -103,6 +103,11 @@
#define PtrOffset(B,O) ((ULONG)((ULONG_PTR)(O) - (ULONG_PTR)(B)))
#endif
+/* MAX_PATH is a Win32 concept, it doesn't belong in the kernel */
+#define MAX_WIN32_PATH 260
+C_ASSERT(MAX_WIN32_PATH == MAX_PATH);
+#undef MAX_PATH
+
//
// Switch for enabling global page support
//