From c13edbee03636be3ff43e88888bf36c13a883e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 13 Aug 2007 14:18:49 +0000 Subject: [PATCH] Take care of lpProfileInfo->lpProfilePath in LoadUserProfileW Return required size in GetUserProfileDirectoryW if buffer is too small svn path=/trunk/; revision=28314 --- reactos/dll/win32/userenv/profile.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/userenv/profile.c b/reactos/dll/win32/userenv/profile.c index 6c35af6a028..d4989a24c14 100644 --- a/reactos/dll/win32/userenv/profile.c +++ b/reactos/dll/win32/userenv/profile.c @@ -766,7 +766,7 @@ GetUserProfileDirectoryW (HANDLE hToken, dwLength = wcslen (szImagePath) + 1; if (*lpcchSize < dwLength) { - DPRINT1 ("Buffer too small\n"); + *lpcchSize = dwLength; SetLastError (ERROR_INSUFFICIENT_BUFFER); return FALSE; } @@ -859,10 +859,18 @@ LoadUserProfileW( return TRUE; } - if (!GetProfilesDirectoryW(szUserHivePath, &dwLength)) + if (lpProfileInfo->lpProfilePath) { - DPRINT1("GetProfilesDirectoryW() failed (error %ld)\n", GetLastError()); - return FALSE; + wcscpy(szUserHivePath, lpProfileInfo->lpProfilePath); + } + else + { + /* FIXME: check if MS Windows allows lpProfileInfo->lpProfilePath to be NULL */ + if (!GetProfilesDirectoryW(szUserHivePath, &dwLength)) + { + DPRINT1("GetProfilesDirectoryW() failed (error %ld)\n", GetLastError()); + return FALSE; + } } wcscat(szUserHivePath, L"\\");