mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-04-17 00:15:25 +00:00
usb: fix possible hang during parsing malformed device descriptor
This commit is contained in:
@@ -323,6 +323,7 @@ static uint8_t asix_parse_conf(usb_device_t *dev, uint8_t conf, uint16_t len) {
|
||||
}
|
||||
|
||||
// advance to next descriptor
|
||||
if (!p->conf_desc.bLength || p->conf_desc.bLength > len) break;
|
||||
len -= p->conf_desc.bLength;
|
||||
p = (union buf_u*)(p->raw + p->conf_desc.bLength);
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ static uint8_t pl2303_parse_conf0(usb_device_t *dev, uint16_t len) {
|
||||
}
|
||||
|
||||
// advance to next descriptor
|
||||
if (!p->conf_desc.bLength || p->conf_desc.bLength > len) break;
|
||||
len -= p->conf_desc.bLength;
|
||||
p = (union buf_u*)(p->raw + p->conf_desc.bLength);
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ static uint8_t usb_xbox_parse_conf(usb_device_t *dev, uint8_t conf, uint16_t len
|
||||
}
|
||||
|
||||
// advance to next descriptor
|
||||
if (!p->conf_desc.bLength || p->conf_desc.bLength > len) break;
|
||||
len -= p->conf_desc.bLength;
|
||||
p = (union buf_u*)(p->raw + p->conf_desc.bLength);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user