From 016c5fd083700250c8430d9740d9774a1eb57fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20S=C5=82abo=C5=84?= Date: Thu, 17 Apr 2025 15:49:38 +0200 Subject: [PATCH] [KERNEL32] RemoveDirectoryW: Fix the code for removing a mounted folder (#7897) - Fix the crash due to copying the memory to wrong destination buffer. - Fix the check for trailing backlash on path string. --- dll/win32/kernel32/client/file/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/win32/kernel32/client/file/dir.c b/dll/win32/kernel32/client/file/dir.c index 16b604deed6..b4594fc5830 100644 --- a/dll/win32/kernel32/client/file/dir.c +++ b/dll/win32/kernel32/client/file/dir.c @@ -919,8 +919,8 @@ RemoveDirectoryW(IN LPCWSTR lpPathName) return FALSE; } - RtlCopyMemory(&PathName.Buffer, lpPathName, PathName.Length); - if (PathName.Buffer[PathName.Length / sizeof(WCHAR)] != L'\\') + RtlCopyMemory(PathName.Buffer, lpPathName, PathName.Length); + if (PathName.Buffer[(PathName.Length / sizeof(WCHAR)) - 1] != L'\\') { PathName.Buffer[PathName.Length / sizeof(WCHAR)] = L'\\'; PathName.Buffer[(PathName.Length / sizeof(WCHAR)) + 1] = UNICODE_NULL;