mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-09-11 18:29:22 -07:00
fix(usb): terminate packet-aligned CDC transfers with ZLP
Send a synchronous zero-length packet after CDC responses whose length is an exact multiple of the endpoint packet size, preventing oversized host reads from remaining pending.
This commit is contained in:
@@ -508,6 +508,21 @@ int usb_write(const uint8_t *data, const size_t len) {
|
|||||||
// Have a cup of tea?
|
// Have a cup of tea?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End a packet-aligned CDC transfer with a zero-length packet. Without
|
||||||
|
// this short packet, a host read larger than this reply can remain pending.
|
||||||
|
// Use the low-level sender: usb_write() intentionally rejects len == 0.
|
||||||
|
// Keep this in the synchronous path, not the asynchronous sample stream.
|
||||||
|
if ((len % USBD_CDC_IN_MAXPACKET_SIZE) == 0) {
|
||||||
|
if (usb_vcp_send_data(udev, (uint8_t *) data, 0) != SUCCESS) {
|
||||||
|
return PM3_EIO;
|
||||||
|
}
|
||||||
|
while (pcdc->g_tx_completed != 1) {
|
||||||
|
if (usb_check() == false) {
|
||||||
|
return PM3_EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user