[ADVAPI32] Don't treat a structure pointer as a string pointer (#5478)

Add a string pointer local variable, assign it and operate on it.
This should eliminate an exception and make LsapIsLocalComputer()
function operate correctly.

CORE-18996
This commit is contained in:
David L Bean 2023-07-26 18:58:44 -04:00 committed by GitHub
parent 4511e62b10
commit dcaf5686ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,15 +23,17 @@ LsapIsLocalComputer(PLSA_UNICODE_STRING ServerName)
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
BOOL Result;
LPWSTR buf;
PCWSTR pSrvName;
if (ServerName == NULL || ServerName->Length == 0 || ServerName->Buffer == NULL)
return TRUE;
pSrvName = ServerName->Buffer;
buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
Result = GetComputerNameW(buf, &dwSize);
if (Result && (ServerName->Buffer[0] == '\\') && (ServerName->Buffer[1] == '\\'))
ServerName += 2;
Result = Result && !lstrcmpW(ServerName->Buffer, buf);
if (Result && (pSrvName[0] == L'\\') && (pSrvName[1] == L'\\'))
pSrvName += 2;
Result = Result && !lstrcmpW(pSrvName, buf);
HeapFree(GetProcessHeap(), 0, buf);
return Result;