mirror of
https://github.com/ddeverill/SteamlessController.git
synced 2026-10-21 14:12:16 -05:00
Fix CancelIo OVERLAPPED drain bug in ReadInputReport
Same latent use-after-free as WriteOutputReport: after CancelIo, the kernel can still complete the IRP and write into the stack OVERLAPPED after the function returns. Block with GetOverlappedResult(..., TRUE) to drain before ov goes out of scope. Co-Authored-By: Dylan Deverill <ddeverill@gmail.com>
This commit is contained in:
1 parent
f7c4f13c90
commit
37cc98b05c
1 file changed
+2
@@ -242,7 +242,9 @@ size_t HidDevice::ReadInputReport(uint8_t* buffer, size_t size, uint32_t timeout
|
||||
|
||||
DWORD wait = WaitForSingleObject(m_event, timeoutMs);
|
||||
if (wait != WAIT_OBJECT_0) {
|
||||
// CancelIo is asynchronous — drain before ov leaves scope.
|
||||
CancelIo(m_handle);
|
||||
GetOverlappedResult(m_handle, &ov, &bytesRead, TRUE);
|
||||
return 0;
|
||||
}
|
||||
if (!GetOverlappedResult(m_handle, &ov, &bytesRead, FALSE))
|
||||
|
||||
Reference in new issue
Block a user