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

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