mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Logging and parser fixes (#7796)
* Fixed remdesk settings pointer * Fixed sign warnings in display_write_monitor_layout_pdu * Use freerdp_abort_connect_context and freerdp_shall_disconnect_context * Added and updates settings * info assert/dynamic timezone * mcs assert/log/flags * Fixed and added assertions for wStream * Unified stream length checks * Added new function to check for lenght and log * Replace all usages with this new function * Cleaned up PER, added parser logging * Cleaned up BER, added parser logging * log messages * Modified Stream_CheckAndLogRequiredLengthEx * Allow custom format and options * Add Stream_CheckAndLogRequiredLengthExVa for prepared va_list * Improved Stream_CheckAndLogRequiredLength * Now have log level adjustable * Added function equivalents for existing logger * Added a backtrace in case of a failure is detected * Fixed public API input checks
This commit is contained in:
@@ -187,11 +187,8 @@ static UINT disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback,
|
||||
context = (DispClientContext*)disp->iface.pInterface;
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
{
|
||||
WLog_ERR(TAG, "not enough remaining data");
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 12))
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, disp->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
|
||||
Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorA); /* MaxMonitorAreaFactorA (4 bytes) */
|
||||
@@ -217,11 +214,8 @@ static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
|
||||
WINPR_ASSERT(callback);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
{
|
||||
WLog_ERR(TAG, "not enough remaining data");
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if ((error = disp_read_header(s, &header)))
|
||||
{
|
||||
|
||||
@@ -34,11 +34,8 @@
|
||||
*/
|
||||
UINT disp_read_header(wStream* s, DISPLAY_CONTROL_HEADER* header)
|
||||
{
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
{
|
||||
WLog_ERR(TAG, "header parsing failed: not enough data!");
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, header->type);
|
||||
Stream_Read_UINT32(s, header->length);
|
||||
|
||||
@@ -133,11 +133,8 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
{
|
||||
WLog_ERR(TAG, "not enough data!");
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, pdu.MonitorLayoutSize); /* MonitorLayoutSize (4 bytes) */
|
||||
|
||||
@@ -157,11 +154,9 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (Stream_GetRemainingLength(s) / DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE < pdu.NumMonitors)
|
||||
{
|
||||
WLog_ERR(TAG, "not enough data!");
|
||||
if (!Stream_CheckAndLogRequiredLength(
|
||||
TAG, s, pdu.NumMonitors * 1ull * DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE))
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
pdu.Monitors = (DISPLAY_CONTROL_MONITOR_LAYOUT*)calloc(pdu.NumMonitors,
|
||||
sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
|
||||
|
||||
Reference in New Issue
Block a user