|
|
083b3c |
From ddf9b3f852c31311f8d726012131f657c9857276 Mon Sep 17 00:00:00 2001
|
|
|
083b3c |
From: akallabeth <akallabeth@posteo.net>
|
|
|
083b3c |
Date: Thu, 13 Oct 2022 08:47:51 +0200
|
|
|
083b3c |
Subject: [PATCH] Fixed missing input buffer length check in urbdrc
|
|
|
083b3c |
|
|
|
083b3c |
(cherry picked from commit 497df00f741dd4fc89292aaef2db7368aee45d0d)
|
|
|
083b3c |
---
|
|
|
083b3c |
channels/urbdrc/client/data_transfer.c | 20 ++++++++++++++++++++
|
|
|
083b3c |
1 file changed, 20 insertions(+)
|
|
|
083b3c |
|
|
|
083b3c |
diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c
|
|
|
083b3c |
index bb2784055..80e84af48 100644
|
|
|
083b3c |
--- a/channels/urbdrc/client/data_transfer.c
|
|
|
083b3c |
+++ b/channels/urbdrc/client/data_transfer.c
|
|
|
083b3c |
@@ -241,6 +241,10 @@ static UINT urbdrc_process_io_control(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* c
|
|
|
083b3c |
|
|
|
083b3c |
Stream_Read_UINT32(s, OutputBufferSize);
|
|
|
083b3c |
Stream_Read_UINT32(s, RequestId);
|
|
|
083b3c |
+
|
|
|
083b3c |
+ if (OutputBufferSize > UINT32_MAX - 4)
|
|
|
083b3c |
+ return ERROR_INVALID_DATA;
|
|
|
083b3c |
+
|
|
|
083b3c |
InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
|
|
|
083b3c |
out = urb_create_iocompletion(InterfaceId, MessageId, RequestId, OutputBufferSize + 4);
|
|
|
083b3c |
|
|
|
083b3c |
@@ -724,6 +728,15 @@ static UINT urb_bulk_or_interrupt_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBA
|
|
|
083b3c |
Stream_Read_UINT32(s, TransferFlags); /** TransferFlags */
|
|
|
083b3c |
Stream_Read_UINT32(s, OutputBufferSize);
|
|
|
083b3c |
EndpointAddress = (PipeHandle & 0x000000ff);
|
|
|
083b3c |
+
|
|
|
083b3c |
+ if (transferDir == USBD_TRANSFER_DIRECTION_OUT)
|
|
|
083b3c |
+ {
|
|
|
083b3c |
+ if (!Stream_CheckAndLogRequiredLength(TAG, s, OutputBufferSize))
|
|
|
083b3c |
+ {
|
|
|
083b3c |
+ return ERROR_INVALID_DATA;
|
|
|
083b3c |
+ }
|
|
|
083b3c |
+ }
|
|
|
083b3c |
+
|
|
|
083b3c |
/** process TS_URB_BULK_OR_INTERRUPT_TRANSFER */
|
|
|
083b3c |
return pdev->bulk_or_interrupt_transfer(
|
|
|
083b3c |
pdev, callback, MessageId, RequestId, EndpointAddress, TransferFlags, noAck,
|
|
|
083b3c |
@@ -808,6 +821,13 @@ static UINT urb_isoch_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback
|
|
|
083b3c |
packetDescriptorData = Stream_Pointer(s);
|
|
|
083b3c |
Stream_Seek(s, NumberOfPackets * 12);
|
|
|
083b3c |
Stream_Read_UINT32(s, OutputBufferSize);
|
|
|
083b3c |
+
|
|
|
083b3c |
+ if (transferDir == USBD_TRANSFER_DIRECTION_OUT)
|
|
|
083b3c |
+ {
|
|
|
083b3c |
+ if (!Stream_CheckAndLogRequiredLength(TAG, s, OutputBufferSize))
|
|
|
083b3c |
+ return ERROR_INVALID_DATA;
|
|
|
083b3c |
+ }
|
|
|
083b3c |
+
|
|
|
083b3c |
return pdev->isoch_transfer(
|
|
|
083b3c |
pdev, callback, MessageId, RequestId, EndpointAddress, TransferFlags, StartFrame,
|
|
|
083b3c |
ErrorCount, noAck, packetDescriptorData, NumberOfPackets, OutputBufferSize,
|
|
|
083b3c |
--
|
|
|
083b3c |
2.37.1
|
|
|
083b3c |
|