Blame SOURCES/Ensure-urb_create_iocompletion-uses-size_t-for-calcu.patch

087af1
From b3a695e9f38a42f1ef0cade0d5e1fe60cf68864e Mon Sep 17 00:00:00 2001
087af1
From: akallabeth <akallabeth@posteo.net>
087af1
Date: Thu, 13 Oct 2022 08:36:26 +0200
087af1
Subject: [PATCH] Ensure urb_create_iocompletion uses size_t for calculation
087af1
087af1
(cherry picked from commit de7e0f062ee53d00b4a966a43855a716e3478150)
087af1
---
087af1
 channels/urbdrc/client/data_transfer.c | 8 +++++++-
087af1
 1 file changed, 7 insertions(+), 1 deletion(-)
087af1
087af1
diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c
087af1
index 80e84af48..8642c8506 100644
087af1
--- a/channels/urbdrc/client/data_transfer.c
087af1
+++ b/channels/urbdrc/client/data_transfer.c
087af1
@@ -97,7 +97,13 @@ static wStream* urb_create_iocompletion(UINT32 InterfaceField, UINT32 MessageId,
087af1
                                         UINT32 OutputBufferSize)
087af1
 {
087af1
 	const UINT32 InterfaceId = (STREAM_ID_PROXY << 30) | (InterfaceField & 0x3FFFFFFF);
087af1
-	wStream* out = Stream_New(NULL, OutputBufferSize + 28);
087af1
+
087af1
+#if UINT32_MAX >= SIZE_MAX
087af1
+	if (OutputBufferSize > UINT32_MAX - 28ull)
087af1
+		return NULL;
087af1
+#endif
087af1
+
087af1
+	wStream* out = Stream_New(NULL, OutputBufferSize + 28ull);
087af1
 
087af1
 	if (!out)
087af1
 		return NULL;
087af1
-- 
087af1
2.37.1
087af1