From 400348012905bbe8bc1b0b45e3192984e37b95ad Mon Sep 17 00:00:00 2001 From: Michael Loh <90074657+AmeNote-Michael@users.noreply.github.com> Date: Thu, 27 Feb 2025 00:36:23 -0500 Subject: [PATCH] Advance of processed data pointers in case of dropped packet. For both write and read USB routines, the processed data was not being advanced in case of invalid cable number. This has been resolved. --- src/api/Drivers/USBMIDI2/Driver/Device.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/api/Drivers/USBMIDI2/Driver/Device.cpp b/src/api/Drivers/USBMIDI2/Driver/Device.cpp index ec7fbafb..c1414475 100644 --- a/src/api/Drivers/USBMIDI2/Driver/Device.cpp +++ b/src/api/Drivers/USBMIDI2/Driver/Device.cpp @@ -2150,6 +2150,8 @@ Return Value: // No need to process further if invalid Cable ID if (!(pDeviceContext->UsbInMask & (0x0001 << cbl_num))) { + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Invalid Data, Received invalid cable number %lu", pReceivedWords[receivedIndex]); + receivedIndex++; // drop the data continue; } @@ -2159,6 +2161,8 @@ Return Value: &pDeviceContext->midi1IsInSysex[cbl_num], &umpPacket)) { + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! USB MIDI 1.0 Packet not processed, parsing error %lu", pReceivedWords[receivedIndex]); + receivedIndex++; // skip the data continue; } @@ -2470,6 +2474,17 @@ Return Value:Amy UINT8 cbl_num = umpPacket.umpData.umpBytes[0] & UMP_GROUP_MASK; // if used, cable num is group block num + // Check to see if valid cable number for USB 1.0 Device + if (!(pDeviceContext->UsbInMask & (0x0001 << cbl_num))) + { + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Invalid Data, Received invalid cable number %d", cbl_num); + // Not handled so ignore + numProcessed += umpPacket.wordCount; // ignore this UMP packet as corrupted + umpWritePacket.wordCount = 0; + + continue; + } + switch (umpPacket.umpData.umpBytes[0] & UMP_MT_MASK) { case UMP_MT_SYSTEM: // System Common messages @@ -3057,7 +3072,6 @@ Return Value: } WdfRequestCompleteWithInformation(Request, status, bytesWritten); - //WdfObjectDelete(Request); return; }