X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-usb_id.c;h=e6c27a901f87427c247d23faff30b1d7314a54ee;hb=e530ed5e1407e0571afc01552e41365ffb01befa;hp=6516d93a3c960e2f24afb4b3df4ec805daf91fd9;hpb=ea79e73b8a8fa72fb959a0604f642f97e200a803;p=elogind.git diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 6516d93a3..e6c27a901 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -150,18 +150,18 @@ static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len _cleanup_close_ int fd = -1; ssize_t size; unsigned char buf[18 + 65535]; - int pos = 0; + size_t pos = 0; unsigned strpos = 0; struct usb_interface_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bInterfaceNumber; - uint8_t bAlternateSetting; - uint8_t bNumEndpoints; - uint8_t bInterfaceClass; - uint8_t bInterfaceSubClass; - uint8_t bInterfaceProtocol; - uint8_t iInterface; + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bInterfaceNumber; + uint8_t bAlternateSetting; + uint8_t bNumEndpoints; + uint8_t bInterfaceClass; + uint8_t bInterfaceSubClass; + uint8_t bInterfaceProtocol; + uint8_t iInterface; } _packed_; if (asprintf(&filename, "%s/descriptors", udev_device_get_syspath(dev)) < 0) @@ -178,7 +178,9 @@ static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len return -EIO; ifs_str[0] = '\0'; - while (pos < size && strpos+7 < len-2) { + while (pos + sizeof(struct usb_interface_descriptor) < (size_t) size && + strpos + 7 < len - 2) { + struct usb_interface_descriptor *desc; char if_str[8];