Author: fireball
Date: Mon Mar 9 12:40:43 2009
New Revision: 39912
URL:
http://svn.reactos.org/svn/reactos?rev=39912&view=rev
Log:
- Fix an incorrect assumption that endpoint descriptors must immediately follow an
interface descriptor (there may be generic descriptors in between too, as it is for e.g.
USB HID devices). Thanks to Michael Lotz from Haiku for his help with this issue.
- Fix incorrect handling of alternate interface settings, which resulted in reading
uninitialized memory.
Modified:
trunk/reactos/drivers/usb/nt4compat/usbdriver/devmgr.c
Modified: trunk/reactos/drivers/usb/nt4compat/usbdriver/devmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/nt4compat/usbd…
==============================================================================
--- trunk/reactos/drivers/usb/nt4compat/usbdriver/devmgr.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/nt4compat/usbdriver/devmgr.c [iso-8859-1] Mon Mar 9
12:40:43 2009
@@ -1200,6 +1200,7 @@
{
LONG i;
PUSB_ENDPOINT_DESC pendp_desc;
+ PBYTE pbuf;
if (pcfg == NULL || pif == NULL || pif_desc == NULL)
return FALSE;
@@ -1218,11 +1219,23 @@
InitializeListHead(&pif->altif_list);
pif->altif_count = 0;
- pendp_desc = (PUSB_ENDPOINT_DESC) (&((PBYTE)
pif_desc)[sizeof(USB_INTERFACE_DESC)]);
-
- for(i = 0; i < pif->endp_count; i++, pendp_desc++)
- {
- dev_mgr_build_usb_endp(pif, &pif->endp[i], pendp_desc);
+ pbuf = &((PBYTE) pif_desc)[sizeof(USB_INTERFACE_DESC)];
+
+ i = 0;
+ while (i < pif->endp_count)
+ {
+ pendp_desc = (PUSB_ENDPOINT_DESC)pbuf;
+
+ // check if it's an endpoint descriptor
+ if (pendp_desc->bDescriptorType == USB_DT_ENDPOINT)
+ {
+ // add it
+ dev_mgr_build_usb_endp(pif, &pif->endp[i], pendp_desc);
+ i++;
+ }
+
+ // skip to the next one
+ pbuf += pendp_desc->bLength;
}
}
else
@@ -1299,8 +1312,7 @@
}
else
{
- i--;
- pif = &pcfg->interf[i];
+ pif = &pcfg->interf[i-1];
dev_mgr_build_usb_if(pcfg, pif, pif_desc, TRUE);
}
}