Skip to content

Commit 456c0d5

Browse files
USB: Check on the number of bytes to send to not send more than expected.
1 parent 3394937 commit 456c0d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: cores/arduino/USB/USBCore.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ int USBD_SendControl(uint8_t flags __attribute__ ((unused)), const void* d, uint
229229

230230
if (_cmark < _cend)
231231
{
232+
if (_cmark + len > _cend)
233+
{
234+
len = _cend - _cmark;
235+
length = len;
236+
}
232237
while (len > 0)
233238
{
234239
sent = UDD_Send(EP0, data + pos, len);

0 commit comments

Comments
 (0)