USBDevice dev;
int fd;
- uint8_t descr[1024];
+ uint8_t descr[8192];
int descr_len;
int configuration;
int ninterfaces;
i = 0;
dev_descr_len = dev->descr[0];
if (dev_descr_len > dev->descr_len) {
- goto fail;
+ fprintf(stderr, "husb: update iface failed. descr too short\n");
+ return 0;
}
i += dev_descr_len;
if (i >= dev->descr_len) {
fprintf(stderr,
"husb: update iface failed. no matching configuration\n");
- goto fail;
+ return 0;
}
nb_interfaces = dev->descr[i + 4];
}
devep = descriptors[i + 2];
+ if ((devep & 0x0f) == 0) {
+ fprintf(stderr, "usb-linux: invalid ep descriptor, ep == 0\n");
+ return 1;
+ }
+
switch (descriptors[i + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
return 0;
fail:
- dev->fd = -1;
- if (fd != -1) {
- close(fd);
+ if (dev->fd != -1) {
+ close(dev->fd);
+ dev->fd = -1;
}
return -1;
}
{
int i;
- if (dev->fd == -1) {
+ if (dev->fd == -1 || !dev->dev.attached) {
return -1;
}
DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
usb_host_open(s, bus_num, addr, port, product_name, speed);
+ break;
}
return 0;