Blame SOURCES/Fixed-division-by-zero-in-urbdrc.patch

083b3c
From b9c5e3668c4022b34734ac8ccb07dd044d4ff38c Mon Sep 17 00:00:00 2001
083b3c
From: akallabeth <akallabeth@posteo.net>
083b3c
Date: Thu, 13 Oct 2022 08:27:41 +0200
083b3c
Subject: [PATCH] Fixed division by zero in urbdrc
083b3c
083b3c
(cherry picked from commit 731f8419d04b481d7160de1f34062d630ed48765)
083b3c
---
083b3c
 channels/urbdrc/client/libusb/libusb_udevice.c | 12 +++++++++---
083b3c
 1 file changed, 9 insertions(+), 3 deletions(-)
083b3c
083b3c
diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c
083b3c
index aa69890ae..5784d9fe2 100644
083b3c
--- a/channels/urbdrc/client/libusb/libusb_udevice.c
083b3c
+++ b/channels/urbdrc/client/libusb/libusb_udevice.c
083b3c
@@ -1214,12 +1214,18 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* c
083b3c
 	if (!Buffer)
083b3c
 		Stream_Seek(user_data->data, (NumberOfPackets * 12));
083b3c
 
083b3c
-	iso_packet_size = BufferSize / NumberOfPackets;
083b3c
-	iso_transfer = libusb_alloc_transfer(NumberOfPackets);
083b3c
+	if (NumberOfPackets > 0)
083b3c
+	{
083b3c
+		iso_packet_size = BufferSize / NumberOfPackets;
083b3c
+		iso_transfer = libusb_alloc_transfer((int)NumberOfPackets);
083b3c
+	}
083b3c
 
083b3c
 	if (iso_transfer == NULL)
083b3c
 	{
083b3c
-		WLog_Print(urbdrc->log, WLOG_ERROR, "Error: libusb_alloc_transfer.");
083b3c
+		WLog_Print(urbdrc->log, WLOG_ERROR,
083b3c
+		           "Error: libusb_alloc_transfer [NumberOfPackets=%" PRIu32 ", BufferSize=%" PRIu32
083b3c
+		           " ]",
083b3c
+		           NumberOfPackets, BufferSize);
083b3c
 		async_transfer_user_data_free(user_data);
083b3c
 		return -1;
083b3c
 	}
083b3c
-- 
083b3c
2.37.1
083b3c