[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.
This commit is contained in:
Adam Słaboń 2025-04-17 15:49:38 +02:00 committed by GitHub
parent 3d9b919814
commit 016c5fd083
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;