[clang,warnings] fix Wjump-misses-init

This commit is contained in:
Armin Novak
2026-01-08 10:32:30 +01:00
parent a177d4af39
commit c607056f93

View File

@@ -474,53 +474,66 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
hModule = LoadLibraryA("winsta.dll");
if (!hModule)
return FALSE;
WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 };
WinStationCreateChildSessionTransportFn createChildSessionFn = GetProcAddressAs(
hModule, "WinStationCreateChildSessionTransport", WinStationCreateChildSessionTransportFn);
if (!createChildSessionFn)
{
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
goto out;
}
WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 };
HRESULT hStatus = createChildSessionFn(pipePath, 0x80);
if (!SUCCEEDED(hStatus))
{
WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus);
goto out;
}
const BYTE startOfPath[] = { '\\', 0, '\\', 0, '.', 0, '\\', 0 };
if (_wcsncmp(pipePath, (const WCHAR*)startOfPath, 4))
{
/* when compiled under 32 bits, the path may miss "\\.\" at the beginning of the string
* so add it if it's not there
*/
size_t len = _wcslen(pipePath);
if (len > 0x80 - (4 + 1))
{
WLog_ERR(TAG, "pipePath is too long to be adjusted");
goto out;
WinStationCreateChildSessionTransportFn createChildSessionFn =
GetProcAddressAs(hModule, "WinStationCreateChildSessionTransport",
WinStationCreateChildSessionTransportFn);
if (!createChildSessionFn)
{
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
goto out;
}
{
HRESULT hStatus = createChildSessionFn(pipePath, 0x80);
if (!SUCCEEDED(hStatus))
{
WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus);
goto out;
}
}
}
memmove(pipePath + 4, pipePath, (len + 1) * sizeof(WCHAR));
memcpy(pipePath, startOfPath, 8);
{
const BYTE startOfPath[] = { '\\', 0, '\\', 0, '.', 0, '\\', 0 };
if (_wcsncmp(pipePath, (const WCHAR*)startOfPath, 4))
{
/* when compiled under 32 bits, the path may miss "\\.\" at the beginning of the
* string so add it if it's not there
*/
size_t len = _wcslen(pipePath);
if (len > 0x80 - (4 + 1))
{
WLog_ERR(TAG, "pipePath is too long to be adjusted");
goto out;
}
memmove(pipePath + 4, pipePath, (len + 1) * sizeof(WCHAR));
memcpy(pipePath, startOfPath, 8);
}
}
(void)ConvertWCharNToUtf8(pipePath, 0x80, pipePathA, sizeof(pipePathA));
WLog_DBG(TAG, "child session is at '%s'", pipePathA);
{
HANDLE f = CreateFileW(pipePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, NULL);
if (f == INVALID_HANDLE_VALUE)
{
WLog_ERR(TAG, "error when connecting to local named pipe");
goto out;
}
*pFile = f;
}
}
(void)ConvertWCharNToUtf8(pipePath, 0x80, pipePathA, sizeof(pipePathA));
WLog_DBG(TAG, "child session is at '%s'", pipePathA);
HANDLE f = CreateFileW(pipePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, NULL);
if (f == INVALID_HANDLE_VALUE)
{
WLog_ERR(TAG, "error when connecting to local named pipe");
goto out;
}
*pFile = f;
ret = TRUE;
out: