https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf8380100eb2221d53f03d...
commit cf8380100eb2221d53f03df08070121e92d5014e Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Sun Dec 12 17:40:52 2021 +0100 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Sun Dec 12 17:40:52 2021 +0100
[KERNEL32] SetComputerNameExW: Truncate the computer name
This fixes the SetComputerNameExW api test. --- dll/win32/kernel32/client/compname.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dll/win32/kernel32/client/compname.c b/dll/win32/kernel32/client/compname.c index 2b4b335d4f7..8b9a5497fb3 100644 --- a/dll/win32/kernel32/client/compname.c +++ b/dll/win32/kernel32/client/compname.c @@ -648,6 +648,7 @@ WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer) { + WCHAR szShortName[MAX_COMPUTERNAME_LENGTH + 1]; BOOL ret1, ret2;
if (!IsValidComputerName(NameType, lpBuffer)) @@ -670,17 +671,19 @@ SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, L"NV Hostname", lpBuffer);
+ RtlStringCchCopyNW(szShortName, ARRAYSIZE(szShortName), lpBuffer, MAX_COMPUTERNAME_LENGTH); ret2 = SetComputerNameToRegistry(L"\Registry\Machine\System\CurrentControlSet" L"\Control\ComputerName\ComputerName", L"ComputerName", - lpBuffer); + szShortName); return (ret1 && ret2);
case ComputerNamePhysicalNetBIOS: + RtlStringCchCopyNW(szShortName, ARRAYSIZE(szShortName), lpBuffer, MAX_COMPUTERNAME_LENGTH); return SetComputerNameToRegistry(L"\Registry\Machine\System\CurrentControlSet" L"\Control\ComputerName\ComputerName", L"ComputerName", - lpBuffer); + szShortName);
default: SetLastError(ERROR_INVALID_PARAMETER);