mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[Analyzers][CPP]Changes to fix warning 26493 on src/common (#23467)
* Changes to fix warning 26493 on src/common It will be multi PR change. This does not turn on the rule but fix the code under src/commom * int cast
This commit is contained in:
@@ -184,9 +184,9 @@ BOOL TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::GetLogonSID(HANDLE hToken,
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
goto Cleanup;
|
||||
|
||||
ptg = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(),
|
||||
ptg = static_cast<PTOKEN_GROUPS>(HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
dwLength);
|
||||
dwLength));
|
||||
|
||||
if (ptg == NULL)
|
||||
goto Cleanup;
|
||||
@@ -213,14 +213,14 @@ BOOL TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::GetLogonSID(HANDLE hToken,
|
||||
// Found the logon SID; make a copy of it.
|
||||
|
||||
dwLength = GetLengthSid(ptg->Groups[dwIndex].Sid);
|
||||
*ppsid = (PSID)HeapAlloc(GetProcessHeap(),
|
||||
*ppsid = static_cast<PSID>(HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
dwLength);
|
||||
dwLength));
|
||||
if (*ppsid == NULL)
|
||||
goto Cleanup;
|
||||
if (!CopySid(dwLength, *ppsid, ptg->Groups[dwIndex].Sid))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, (LPVOID)*ppsid);
|
||||
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(*ppsid));
|
||||
goto Cleanup;
|
||||
}
|
||||
break;
|
||||
@@ -233,7 +233,7 @@ Cleanup:
|
||||
// Free the buffer for the token groups.
|
||||
|
||||
if (ptg != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, (LPVOID)ptg);
|
||||
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(ptg));
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ Cleanup:
|
||||
VOID TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::FreeLogonSID(PSID* ppsid)
|
||||
{
|
||||
// From https://learn.microsoft.com/previous-versions/aa446670(v=vs.85)
|
||||
HeapFree(GetProcessHeap(), 0, (LPVOID)*ppsid);
|
||||
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(*ppsid));
|
||||
}
|
||||
|
||||
int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_restricted_token(HANDLE handle, HANDLE token)
|
||||
@@ -279,7 +279,7 @@ int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_r
|
||||
ea.grfInheritance = NO_INHERITANCE;
|
||||
ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
ea.Trustee.TrusteeType = TRUSTEE_IS_USER;
|
||||
ea.Trustee.ptstrName = (LPTSTR)user_restricted;
|
||||
ea.Trustee.ptstrName = static_cast<LPTSTR>(user_restricted);
|
||||
|
||||
if (SetEntriesInAcl(1, &ea, old_dacl, &new_dacl))
|
||||
{
|
||||
@@ -302,9 +302,9 @@ int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_r
|
||||
error = 0;
|
||||
|
||||
Lclean_dacl:
|
||||
LocalFree((HLOCAL)new_dacl);
|
||||
LocalFree(static_cast<HLOCAL>(new_dacl));
|
||||
Lclean_sd:
|
||||
LocalFree((HLOCAL)sd);
|
||||
LocalFree(static_cast<HLOCAL>(sd));
|
||||
Lclean_sid:
|
||||
FreeLogonSID(&user_restricted);
|
||||
Ldone:
|
||||
|
||||
Reference in New Issue
Block a user