Skip unexpected descriptors
This commit is contained in:
parent
fafc23e90a
commit
443a6c4b21
2 changed files with 17 additions and 2 deletions
|
@ -209,14 +209,23 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Skip the configuration descriptor. */
|
/* Skip the configuration descriptor. */
|
||||||
pos = sizeof (struct grub_usb_desc_config);
|
pos = dev->config[i].descconf->length;
|
||||||
|
|
||||||
/* Read all interfaces. */
|
/* Read all interfaces. */
|
||||||
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
||||||
{
|
{
|
||||||
|
while (pos < config.totallen
|
||||||
|
&& ((struct grub_usb_desc *)&data[pos])->type
|
||||||
|
!= GRUB_USB_DESCRIPTOR_INTERFACE)
|
||||||
|
pos += ((struct grub_usb_desc *)&data[pos])->length;
|
||||||
dev->config[i].interf[currif].descif
|
dev->config[i].interf[currif].descif
|
||||||
= (struct grub_usb_desc_if *) &data[pos];
|
= (struct grub_usb_desc_if *) &data[pos];
|
||||||
pos += sizeof (struct grub_usb_desc_if);
|
pos += dev->config[i].interf[currif].descif->length;
|
||||||
|
|
||||||
|
while (pos < config.totallen
|
||||||
|
&& ((struct grub_usb_desc *)&data[pos])->type
|
||||||
|
!= GRUB_USB_DESCRIPTOR_ENDPOINT)
|
||||||
|
pos += ((struct grub_usb_desc *)&data[pos])->length;
|
||||||
|
|
||||||
/* Point to the first endpoint. */
|
/* Point to the first endpoint. */
|
||||||
dev->config[i].interf[currif].descendp
|
dev->config[i].interf[currif].descendp
|
||||||
|
|
|
@ -31,6 +31,12 @@ typedef enum {
|
||||||
GRUB_USB_DESCRIPTOR_HUB = 0x29
|
GRUB_USB_DESCRIPTOR_HUB = 0x29
|
||||||
} grub_usb_descriptor_t;
|
} grub_usb_descriptor_t;
|
||||||
|
|
||||||
|
struct grub_usb_desc
|
||||||
|
{
|
||||||
|
grub_uint8_t length;
|
||||||
|
grub_uint8_t type;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct grub_usb_desc_device
|
struct grub_usb_desc_device
|
||||||
{
|
{
|
||||||
grub_uint8_t length;
|
grub_uint8_t length;
|
||||||
|
|
Loading…
Reference in a new issue