Reactos

[KERNEL32] SetComputerNameExW: Truncate the computer name

This fixes the SetComputerNameExW api test.

+5 -2
+5 -2
dll/win32/kernel32/client/compname.c
··· 648 648 SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, 649 649 LPCWSTR lpBuffer) 650 650 { 651 + WCHAR szShortName[MAX_COMPUTERNAME_LENGTH + 1]; 651 652 BOOL ret1, ret2; 652 653 653 654 if (!IsValidComputerName(NameType, lpBuffer)) ··· 670 671 L"NV Hostname", 671 672 lpBuffer); 672 673 674 + RtlStringCchCopyNW(szShortName, ARRAYSIZE(szShortName), lpBuffer, MAX_COMPUTERNAME_LENGTH); 673 675 ret2 = SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" 674 676 L"\\Control\\ComputerName\\ComputerName", 675 677 L"ComputerName", 676 - lpBuffer); 678 + szShortName); 677 679 return (ret1 && ret2); 678 680 679 681 case ComputerNamePhysicalNetBIOS: 682 + RtlStringCchCopyNW(szShortName, ARRAYSIZE(szShortName), lpBuffer, MAX_COMPUTERNAME_LENGTH); 680 683 return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" 681 684 L"\\Control\\ComputerName\\ComputerName", 682 685 L"ComputerName", 683 - lpBuffer); 686 + szShortName); 684 687 685 688 default: 686 689 SetLastError(ERROR_INVALID_PARAMETER);