https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f47afc3b61cc182bfe4ee…
commit f47afc3b61cc182bfe4ee8cf95bf62a4e03659c6
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Jun 16 19:44:56 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Aug 19 22:18:30 2018 +0200
[WIN32K:NTUSER] In UserCreateWinstaDirectory(), use a string-safe printf, and use
OBJ_KERNEL_HANDLE as well as a suitable desired access value in a
ZwCreateDirectoryObject() call.
---
win32ss/user/ntuser/winsta.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/win32ss/user/ntuser/winsta.c b/win32ss/user/ntuser/winsta.c
index 44a8f40505..901897857b 100644
--- a/win32ss/user/ntuser/winsta.c
+++ b/win32ss/user/ntuser/winsta.c
@@ -47,11 +47,11 @@ NTSTATUS
NTAPI
UserCreateWinstaDirectory(VOID)
{
- PPEB Peb;
NTSTATUS Status;
- WCHAR wstrWindowStationsDir[MAX_PATH];
+ PPEB Peb;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hWinstaDir;
+ WCHAR wstrWindowStationsDir[MAX_PATH];
/* Create the WindowStations directory and cache its path for later use */
Peb = NtCurrentPeb();
@@ -64,11 +64,14 @@ UserCreateWinstaDirectory(VOID)
}
else
{
- swprintf(wstrWindowStationsDir,
- L"%ws\\%lu%ws",
- SESSION_DIR,
- Peb->SessionId,
- WINSTA_OBJ_DIR);
+ Status = RtlStringCbPrintfW(wstrWindowStationsDir,
+ sizeof(wstrWindowStationsDir),
+ L"%ws\\%lu%ws",
+ SESSION_DIR,
+ Peb->SessionId,
+ WINSTA_OBJ_DIR);
+ if (!NT_SUCCESS(Status))
+ return Status;
if (!RtlCreateUnicodeString(&gustrWindowStationsDir, wstrWindowStationsDir))
{
@@ -78,10 +81,10 @@ UserCreateWinstaDirectory(VOID)
InitializeObjectAttributes(&ObjectAttributes,
&gustrWindowStationsDir,
- 0,
+ OBJ_KERNEL_HANDLE,
NULL,
NULL);
- Status = ZwCreateDirectoryObject(&hWinstaDir, 0, &ObjectAttributes);
+ Status = ZwCreateDirectoryObject(&hWinstaDir, DIRECTORY_CREATE_OBJECT,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
ERR("Could not create %wZ directory (Status 0x%X)\n",
&gustrWindowStationsDir, Status);