usb_rndis: fix handling of multiple packets in one USB transaction
I got my pointer math wrong because some things in RNDIS use uint32 as the base, but some things are in bytes. Most of the time this would result in an offset past the end of the USB buffer, so it would just lead to ignoring all but the first packet. But if the first packet was small enough, it would point somewhere still in the buffer, and we would read the wrong data. Fixes #17775 Change-Id: I32ec0081336b1f772d4dc3099a0ac2c691aa12f0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5377 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
4dda1c0369
commit
fb02142782
@@ -316,7 +316,9 @@ RNDISDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
fReadHeader[1], fReadHeader[2], fReadHeader[3]);
|
||||
|
||||
// Advance to next packet
|
||||
fReadHeader += fReadHeader[1];
|
||||
fReadHeader = (uint32*)((uint8*)fReadHeader + fReadHeader[1]);
|
||||
|
||||
// Are we past the end of the buffer? If so, prepare to receive another one on the next read
|
||||
if ((uint32)((uint8*)fReadHeader - fReadBuffer) >= fActualLengthRead)
|
||||
fReadHeader = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user