adafruit / ArduinoCore-samd

114 stars 116 forks source link

Bug in USBDeviceClass.sendStringDecscriptor/sendDescriptor may send malformed descriptors. #350

Closed alphaleonis closed 7 months ago

alphaleonis commented 7 months ago

sendStringDescriptor accepts a uint8_t as maxlen, however calling code (from sendDescriptor) passes in wLength from the request packet, which is an uint16_t and may be larger than 255, causing maxlen to be truncated and an invalid packet sent.

This has been fixed in the upstream, so catching up with that would fix the issue.

(The issue occurred for me on Windows which sends 2050 as wLength in the Get descriptor request, which is truncated to one bytes causing sendDescriptor to send an essentially empty packet with incorrect length).

hathach commented 7 months ago

thank for reporting this issue, pr #351 update code following upstream, would you mind testing it out ?

alphaleonis commented 7 months ago

The changes you made in #351 are identical to the ones I already tested out locally and seems to work like a charm. :)