[winpr,stream] Check Stream_SetLength return

This commit is contained in:
Armin Novak
2026-03-02 10:54:55 +01:00
parent b8c32fbdd5
commit 5a532269ef
20 changed files with 106 additions and 59 deletions

View File

@@ -478,7 +478,9 @@ static UINT ainput_process_message(ainput_server* ainput)
goto out;
}
Stream_SetLength(s, ActualBytesReturned);
if (!Stream_SetLength(s, ActualBytesReturned))
goto out;
{
const UINT16 MessageId = Stream_Get_UINT16(s);

View File

@@ -400,7 +400,12 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
break;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
{
error = ERROR_INTERNAL_ERROR;
break;
}
if (!Stream_CheckAndLogRequiredLengthWLog(audin->log, s, SNDIN_HEADER_SIZE))
{
error = ERROR_INTERNAL_ERROR;

View File

@@ -322,7 +322,9 @@ static UINT disp_server_handle_messages(DispServerContext* context)
return ERROR_INTERNAL_ERROR;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
return ERROR_INTERNAL_ERROR;
Stream_ResetPosition(s);
while (Stream_GetPosition(s) < Stream_Length(s))

View File

@@ -252,7 +252,9 @@ static UINT gfxredir_server_handle_messages(GfxRedirServerContext* context)
return ERROR_INTERNAL_ERROR;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
return ERROR_INTERNAL_ERROR;
Stream_ResetPosition(s);
while (Stream_GetPosition(s) < Stream_Length(s))

View File

@@ -348,7 +348,9 @@ static UINT location_process_message(location_server* location)
goto out;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
goto out;
if (!Stream_CheckAndLogRequiredLength(TAG, s, LOCATION_HEADER_SIZE))
return ERROR_NO_DATA;

View File

@@ -2250,7 +2250,11 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
if (BytesReturned >= RDPDR_HEADER_LENGTH)
{
Stream_ResetPosition(s);
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
{
error = ERROR_INTERNAL_ERROR;
goto out_stream;
}
while (Stream_GetRemainingLength(s) >= RDPDR_HEADER_LENGTH)
{

View File

@@ -298,7 +298,9 @@ static UINT enumerator_process_message(enumerator_server* enumerator)
goto out;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
return ERROR_INTERNAL_ERROR;
if (!Stream_CheckAndLogRequiredLength(TAG, s, CAM_HEADER_SIZE))
return ERROR_NO_DATA;

View File

@@ -504,7 +504,9 @@ static UINT device_process_message(device_server* device)
goto out;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
goto out;
if (!Stream_CheckAndLogRequiredLength(TAG, s, CAM_HEADER_SIZE))
return ERROR_NO_DATA;

View File

@@ -271,7 +271,9 @@ static UINT mouse_cursor_process_message(mouse_cursor_server* mouse_cursor)
goto out;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
goto out;
if (!Stream_CheckAndLogRequiredLength(TAG, s, RDPEMSC_HEADER_SIZE))
return ERROR_NO_DATA;

View File

@@ -1869,7 +1869,9 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
return ERROR_INTERNAL_ERROR;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
return ERROR_INTERNAL_ERROR;
Stream_ResetPosition(s);
while (Stream_GetPosition(s) < Stream_Length(s))

View File

@@ -181,7 +181,9 @@ static UINT telemetry_process_message(telemetry_server* telemetry)
goto out;
}
Stream_SetLength(s, BytesReturned);
if (!Stream_SetLength(s, BytesReturned))
goto out;
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
return ERROR_NO_DATA;