Re: [1/3] secur32: Implement GetUserNameEx(NameSamCompatible)
"Ge van Geldorp" <ge(a)gse.nl> writes:
@@ -1055,15 +1056,86 @@ BOOLEAN WINAPI GetComputerObjectNameW( BOOLEAN WINAPI GetUserNameExA( EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize) { - FIXME("%d %p %p\n", NameFormat, lpNameBuffer, nSize); - return FALSE; + BOOLEAN rc; + LPWSTR bufferW = NULL; + ULONG sizeW = *nSize; + TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize); + if (lpNameBuffer) { + bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR)); + if (bufferW == NULL) { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + rc = GetUserNameExW(NameFormat, bufferW, &sizeW); + if (rc && bufferW) { + ULONG len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, bufferW, -1, lpNameBuffer, *nSize, NULL, NULL); + *nSize = len; + }
You need to check for buffer overflows and return the appropriate error, preferably with test cases. -- Alexandre Julliard julliard(a)winehq.org
participants (1)
-
Alexandre Julliard