Commit 652090f5 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

secur32: Fix GetComputerObjectNameW for the cases of NULL or insufficient buffer size.

parent e2cbfb68
......@@ -996,29 +996,21 @@ BOOLEAN WINAPI GetComputerObjectNameW(
if (GetComputerNameW(name, &size))
{
DWORD len = domainInfo->Name.Length + size + 3;
if (lpNameBuffer)
if (lpNameBuffer && *nSize >= len)
{
if (*nSize < len)
{
*nSize = len;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
status = FALSE;
}
else
{
WCHAR bs[] = { '\\', 0 };
WCHAR ds[] = { '$', 0 };
lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
lstrcatW(lpNameBuffer, bs);
lstrcatW(lpNameBuffer, name);
lstrcatW(lpNameBuffer, ds);
status = TRUE;
}
WCHAR bs[] = { '\\', 0 };
WCHAR ds[] = { '$', 0 };
lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
lstrcatW(lpNameBuffer, bs);
lstrcatW(lpNameBuffer, name);
lstrcatW(lpNameBuffer, ds);
status = TRUE;
}
else /* just requesting length required */
{
*nSize = len;
status = TRUE;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
status = FALSE;
}
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment