Fixed invalid buffer length and duplicated write function.
authorakallabeth <akallabeth@posteo.net>
Thu, 9 Jul 2020 10:20:48 +0000 (12:20 +0200)
committerakallabeth <akallabeth@users.noreply.github.com>
Tue, 1 Dec 2020 14:10:23 +0000 (15:10 +0100)
(cherry picked from commit 54c92e78e6031d1e075625699e2d677af583716a)

channels/urbdrc/client/data_transfer.c
channels/urbdrc/client/libusb/libusb_udevice.c
channels/urbdrc/common/urbdrc_helpers.c

index fe6768c..d67c33c 100644 (file)
@@ -765,9 +765,7 @@ static void urb_isoch_transfer_cb(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callb
                Stream_Write_UINT32(out, OutputBufferSize); /** OutputBufferSize */
                Stream_Seek(out, OutputBufferSize);
 
-               if (!pdev->isChannelClosed(pdev))
-                       callback->channel->Write(callback->channel, Stream_GetPosition(out), Stream_Buffer(out),
-                                                NULL);
+               stream_write_and_free(callback->plugin, callback->channel, out);
        }
 }
 
index 0332e28..85e15ff 100644 (file)
@@ -924,7 +924,10 @@ static int libusb_udev_os_feature_descriptor_request(IUDEVICE* idev, UINT32 Requ
                                                LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | Recipient,
                                                bMS_Vendorcode, (InterfaceNumber << 8) | Ms_PageIndex,
                                                Ms_featureDescIndex, Buffer, *BufferSize, Timeout);
-               *BufferSize = error;
+               log_libusb_result(pdev->urbdrc->log, WLOG_DEBUG, "libusb_control_transfer", error);
+
+               if (error >= 0)
+                       *BufferSize = error;
        }
 
        if (error < 0)
index 80d6149..53c3b89 100644 (file)
@@ -391,7 +391,7 @@ void urbdrc_dump_message(wLog* log, BOOL client, BOOL write, wStream* s)
        pos = Stream_GetPosition(s);
        if (write)
        {
-               length = Stream_GetPosition(s);
+               length = pos;
                Stream_SetPosition(s, 0);
        }
        else
@@ -407,7 +407,7 @@ void urbdrc_dump_message(wLog* log, BOOL client, BOOL write, wStream* s)
 
        WLog_Print(log, WLOG_DEBUG,
                   "[%-5s] %s [%08" PRIx32 "] InterfaceId=%08" PRIx32 ", MessageId=%08" PRIx32
-                  ", FunctionId=%08" PRIx32 ", length=%" PRIdz,
+                  ", FunctionId=%08" PRIx32 ", length=%" PRIuz,
                   type, call_to_string(client, InterfaceId, FunctionId), FunctionId, InterfaceId,
                   MessageId, FunctionId, length);
 #if defined(WITH_DEBUG_URBDRC)