detect short descriptor reads
authorDaniel Drake <dsd@gentoo.org>
Fri, 2 May 2008 11:55:34 +0000 (12:55 +0100)
committerDaniel Drake <dsd@gentoo.org>
Fri, 2 May 2008 11:55:34 +0000 (12:55 +0100)
libusb/os/linux_usbfs.c

index a678032..30cb9b9 100644 (file)
@@ -166,7 +166,11 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
                usbi_err("read failed ret=%d errno=%d", r, errno);
                goto err;
        }
-       /* FIXME: short read handling? */
+       if (r < DEVICE_DESC_LENGTH) {
+               usbi_err("short descriptor read %d/%d", r, DEVICE_DESC_LENGTH);
+               r = -EIO;
+               goto err;
+       }
 
        usbi_parse_descriptor(raw_desc, "bbWbbbbWWWbbbb", &dev->desc);