From 7857b6c7e9e261834d5a673004adbacfed4052c4 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 19 Nov 2004 20:02:47 +0000 Subject: [PATCH] report proper buffer sizes as documented svn path=/trunk/; revision=11701 --- reactos/lib/userenv/profile.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/reactos/lib/userenv/profile.c b/reactos/lib/userenv/profile.c index cd22f74a408..b5e1380d8a4 100644 --- a/reactos/lib/userenv/profile.c +++ b/reactos/lib/userenv/profile.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: profile.c,v 1.16 2004/11/08 21:23:34 weiden Exp $ +/* $Id: profile.c,v 1.17 2004/11/19 20:02:47 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -351,7 +351,7 @@ GetAllUsersProfileDirectoryW (LPWSTR lpProfileDir, } /* Get profiles path */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); if (RegQueryValueExW (hKey, L"ProfilesDirectory", NULL, @@ -375,7 +375,7 @@ GetAllUsersProfileDirectoryW (LPWSTR lpProfileDir, } /* Get 'AllUsersProfile' name */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); if (RegQueryValueExW (hKey, L"AllUsersProfile", NULL, @@ -393,7 +393,7 @@ GetAllUsersProfileDirectoryW (LPWSTR lpProfileDir, wcscat (szProfilePath, L"\\"); wcscat (szProfilePath, szBuffer); - dwLength = wcslen (szProfilePath); + dwLength = wcslen (szProfilePath) + 1; if (lpProfileDir != NULL) { if (*lpcchSize < dwLength) @@ -464,7 +464,7 @@ GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDir, } /* Get profiles path */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); if (RegQueryValueExW (hKey, L"ProfilesDirectory", NULL, @@ -488,7 +488,7 @@ GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDir, } /* Get 'DefaultUserProfile' name */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); if (RegQueryValueExW (hKey, L"DefaultUserProfile", NULL, @@ -506,7 +506,7 @@ GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDir, wcscat (szProfilePath, L"\\"); wcscat (szProfilePath, szBuffer); - dwLength = wcslen (szProfilePath); + dwLength = wcslen (szProfilePath) + 1; if (lpProfileDir != NULL) { if (*lpcchSize < dwLength) @@ -577,7 +577,7 @@ GetProfilesDirectoryW (LPWSTR lpProfilesDir, } /* Get profiles path */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); if (RegQueryValueExW (hKey, L"ProfilesDirectory", NULL, @@ -601,12 +601,12 @@ GetProfilesDirectoryW (LPWSTR lpProfilesDir, return FALSE; } - dwLength = wcslen (szProfilesPath); + dwLength = wcslen (szProfilesPath) + 1; if (lpProfilesDir != NULL) { - if (*lpcchSize < dwLength / sizeof(WCHAR)) + if (*lpcchSize < dwLength) { - *lpcchSize = dwLength / sizeof(WCHAR); + *lpcchSize = dwLength; SetLastError (ERROR_INSUFFICIENT_BUFFER); return FALSE; } @@ -694,7 +694,7 @@ GetUserProfileDirectoryW (HANDLE hToken, return FALSE; } - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szRawImagePath); if (RegQueryValueExW (hKey, L"ProfileImagePath", NULL, @@ -722,8 +722,8 @@ GetUserProfileDirectoryW (HANDLE hToken, DPRINT ("ImagePath: '%S'\n", szImagePath); - dwLength = wcslen (szImagePath); - if (dwLength > *lpcchSize) + dwLength = wcslen (szImagePath) + 1; + if (*lpcchSize < dwLength) { DPRINT1 ("Buffer too small\n"); SetLastError (ERROR_INSUFFICIENT_BUFFER);