From 511f9e810a1aeff438ccd79fc4a4ccfa4d1e018a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 3 Feb 2016 11:04:35 +0100 Subject: [PATCH] Use ERROR_INVALID_DATA for short buffers. --- channels/rdpdr/client/irp.c | 2 +- channels/rdpdr/client/rdpdr_capabilities.c | 24 +++++++++++----------- channels/rdpdr/client/rdpdr_main.c | 14 ++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c index d98870d9d..d8eaece36 100644 --- a/channels/rdpdr/client/irp.c +++ b/channels/rdpdr/client/irp.c @@ -86,7 +86,7 @@ IRP* irp_new(DEVMAN* devman, wStream* s, UINT* error) if (Stream_GetRemainingLength(s) < 20) { if (error) - *error = CHANNEL_RC_NO_BUFFER; + *error = ERROR_INVALID_DATA; return NULL; } diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index ad216e6f2..4ff3ef594 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -66,12 +66,12 @@ static UINT rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* s) UINT16 capabilityLength; if (Stream_GetRemainingLength(s) < 2) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityLength); if (Stream_GetRemainingLength(s) < capabilityLength - 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Seek(s, capabilityLength - 4); @@ -90,12 +90,12 @@ static UINT rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* s) UINT16 capabilityLength; if (Stream_GetRemainingLength(s) < 2) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityLength); if (Stream_GetRemainingLength(s) < capabilityLength - 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Seek(s, capabilityLength - 4); @@ -114,12 +114,12 @@ static UINT rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* s) UINT16 capabilityLength; if (Stream_GetRemainingLength(s) < 2) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityLength); if (Stream_GetRemainingLength(s) < capabilityLength - 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Seek(s, capabilityLength - 4); @@ -138,12 +138,12 @@ static UINT rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* s) UINT16 capabilityLength; if (Stream_GetRemainingLength(s) < 2) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityLength); if (Stream_GetRemainingLength(s) < capabilityLength - 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Seek(s, capabilityLength - 4); @@ -162,12 +162,12 @@ static UINT rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* s) UINT16 capabilityLength; if (Stream_GetRemainingLength(s) < 2) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityLength); if (Stream_GetRemainingLength(s) < capabilityLength - 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Seek(s, capabilityLength - 4); @@ -185,7 +185,7 @@ UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s) return CHANNEL_RC_NULL_DATA; if (Stream_GetRemainingLength(s) < 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, numCapabilities); Stream_Seek(s, 2); /* pad (2 bytes) */ @@ -193,7 +193,7 @@ UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s) for (i = 0; i < numCapabilities; i++) { if (Stream_GetRemainingLength(s) < sizeof(UINT16)) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, capabilityType); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 62da00b51..87ee6fbdb 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -665,7 +665,7 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr) static UINT rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr, wStream* s) { if (Stream_GetRemainingLength(s) < 8) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, rdpdr->versionMajor); Stream_Read_UINT16(s, rdpdr->versionMinor); @@ -746,7 +746,7 @@ static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr, wStream* s UINT32 clientID; if (Stream_GetRemainingLength(s) < 8) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, versionMajor); Stream_Read_UINT16(s, versionMinor); @@ -819,7 +819,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use if (!Stream_EnsureRemainingCapacity(s, 20 + data_len)) { WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!"); - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; } Stream_Write_UINT32(s, device->type); /* deviceType */ @@ -934,7 +934,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s) return CHANNEL_RC_NULL_DATA; if (Stream_GetRemainingLength(s) < 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT16(s, component); /* Component (2 bytes) */ Stream_Read_UINT16(s, packetId); /* PacketId (2 bytes) */ @@ -995,7 +995,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s) case PAKID_CORE_DEVICE_REPLY: /* connect to a specific resource */ if (Stream_GetRemainingLength(s) < 8) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT32(s, deviceId); Stream_Read_UINT32(s, status); @@ -1025,7 +1025,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s) { UINT32 eventID; if (Stream_GetRemainingLength(s) < 4) - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; Stream_Read_UINT32(s, eventID); WLog_ERR(TAG, "Ignoring unhandled message PAKID_PRN_CACHE_DATA (EventID: 0x%04X)", eventID); @@ -1216,7 +1216,7 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr, if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength)) { WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!"); - return CHANNEL_RC_NO_BUFFER; + return ERROR_INVALID_DATA; } Stream_Write(data_in, pData, dataLength);