summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2024-11-28 11:03:17 +0700
committerGitHub <[email protected]>2024-11-28 11:03:17 +0700
commit31429271141e5af70bbcbe28804442d4f2ffb9ba (patch)
tree0a57dd4592f3646ec38596fa125b4b1143338d31 /src/host
parent5bb90efd5ff59d3b1d67f3c9269ce1aa57a925a6 (diff)
parent3cacb01459670ed20b094ebafc97812437fc173f (diff)
Merge pull request #2852 from GuavTek/recover_zero_length_desc
USBH: Recover from unexpected descriptor size
Diffstat (limited to 'src/host')
-rw-r--r--src/host/usbh.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index a9a692455..a2994cde7 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -1654,6 +1654,13 @@ static bool _parse_configuration_descriptor(uint8_t dev_addr, tusb_desc_configur
// parse each interfaces
while( p_desc < desc_end ) {
+ if ( 0 == tu_desc_len(p_desc) ) {
+ // A zero length descriptor indicates that the device is off spec (e.g. wrong wTotalLength).
+ // Parsed interfaces should still be usable
+ TU_LOG_USBH("Encountered a zero-length descriptor after %u bytes\r\n", (uint32_t)p_desc - (uint32_t)desc_cfg);
+ break;
+ }
+
uint8_t assoc_itf_count = 1;
// Class will always starts with Interface Association (if any) and then Interface descriptor