projects
/
pub
/
lufa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Documentation: Update changelog.
[pub/lufa.git]
/
LUFA
/
Drivers
/
USB
/
Class
/
Device
/
RNDISClassDevice.c
diff --git
a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c
b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c
index
cb96c5e
..
1cbc31d
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c
+++ b/
LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c
@@
-441,7
+441,8
@@
bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInte
uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,
void* Buffer,
uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,
void* Buffer,
- uint16_t* const PacketLength)
+ const uint16_t BufferSize,
+ uint16_t* PacketLength)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) ||
(RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized))
{
if ((USB_DeviceState != DEVICE_STATE_Configured) ||
(RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized))
@@
-449,10
+450,10
@@
uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa
return ENDPOINT_RWSTREAM_DeviceDisconnected;
}
return ENDPOINT_RWSTREAM_DeviceDisconnected;
}
- Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);
-
*PacketLength = 0;
*PacketLength = 0;
+ Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);
+
if (!(Endpoint_IsOUTReceived()))
return ENDPOINT_RWSTREAM_NoError;
if (!(Endpoint_IsOUTReceived()))
return ENDPOINT_RWSTREAM_NoError;
@@
-466,9
+467,16
@@
uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa
return RNDIS_ERROR_LOGICAL_CMD_FAILED;
}
return RNDIS_ERROR_LOGICAL_CMD_FAILED;
}
- *PacketLength = (uint16_t)le32_to_cpu(RNDISPacketHeader.DataLength);
+ const size_t ExpectedLength = (uint16_t)le32_to_cpu(RNDISPacketHeader.DataLength);
+
+ if (ExpectedLength > BufferSize)
+ *PacketLength = BufferSize;
+ else
+ *PacketLength = ExpectedLength;
Endpoint_Read_Stream_LE(Buffer, *PacketLength, NULL);
Endpoint_Read_Stream_LE(Buffer, *PacketLength, NULL);
+ if (ExpectedLength > BufferSize)
+ Endpoint_Discard_Stream(ExpectedLength - BufferSize, NULL);
Endpoint_ClearOUT();
return ENDPOINT_RWSTREAM_NoError;
Endpoint_ClearOUT();
return ENDPOINT_RWSTREAM_NoError;