diff --git a/dll/win32/msv1_0/msv1_0.c b/dll/win32/msv1_0/msv1_0.c index c5d87f88c2d..38bdbc40179 100644 --- a/dll/win32/msv1_0/msv1_0.c +++ b/dll/win32/msv1_0/msv1_0.c @@ -1183,7 +1183,8 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, NTSTATUS Status; PMSV1_0_INTERACTIVE_LOGON LogonInfo; - WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + UNICODE_STRING ComputerName; + WCHAR ComputerNameData[MAX_COMPUTERNAME_LENGTH + 1]; SAMPR_HANDLE ServerHandle = NULL; SAMPR_HANDLE DomainHandle = NULL; SAMPR_HANDLE UserHandle = NULL; @@ -1214,6 +1215,15 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, *AccountName = NULL; *AuthenticatingAuthority = NULL; + /* Get the computer name */ + ComputerNameSize = ARRAYSIZE(ComputerNameData); + if (!GetComputerNameW(ComputerNameData, &ComputerNameSize)) + { + ERR("Failed to get Computername.\n"); + return STATUS_INTERNAL_ERROR; + } + RtlInitUnicodeString(&ComputerName, ComputerNameData); + /* Parameters validation */ if (LogonType == Interactive || LogonType == Batch || @@ -1330,10 +1340,6 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, /* Get the logon time */ NtQuerySystemTime(&LogonTime); - /* Get the computer name */ - ComputerNameSize = ARRAYSIZE(ComputerName); - GetComputerNameW(ComputerName, &ComputerNameSize); - /* Check for special accounts */ // FIXME: Windows does not do this that way!! (msv1_0 does not contain these hardcoded values) if (RtlEqualUnicodeString(&LogonInfo->LogonDomainName, &NtAuthorityU, TRUE)) @@ -1546,7 +1552,7 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, } /* Check workstations */ - if (!MsvpCheckWorkstations(&UserInfo->All.WorkStations, ComputerName)) + if (!MsvpCheckWorkstations(&UserInfo->All.WorkStations, ComputerNameData)) { ERR("Invalid workstation!\n"); *SubStatus = STATUS_INVALID_WORKSTATION; @@ -1579,7 +1585,7 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, /* Build and fill the interactive profile buffer */ Status = BuildInteractiveProfileBuffer(ClientRequest, UserInfo, - ComputerName, + ComputerNameData, (PMSV1_0_INTERACTIVE_PROFILE*)ProfileBuffer, ProfileBufferSize); if (!NT_SUCCESS(Status)) @@ -1659,12 +1665,12 @@ done: *MachineName = DispatchTable.AllocateLsaHeap(sizeof(UNICODE_STRING)); if (*MachineName != NULL) { - (*MachineName)->Buffer = DispatchTable.AllocateLsaHeap((ComputerNameSize + 1) * sizeof(WCHAR)); + (*MachineName)->Buffer = DispatchTable.AllocateLsaHeap(ComputerName.MaximumLength); if ((*MachineName)->Buffer != NULL) { - (*MachineName)->MaximumLength = (ComputerNameSize + 1) * sizeof(WCHAR); - (*MachineName)->Length = ComputerNameSize * sizeof(WCHAR); - RtlCopyMemory((*MachineName)->Buffer, ComputerName, (*MachineName)->MaximumLength); + (*MachineName)->MaximumLength = ComputerName.MaximumLength; + (*MachineName)->Length = ComputerName.Length; + RtlCopyMemory((*MachineName)->Buffer, ComputerName.Buffer, ComputerName.MaximumLength); } }