Fixed dissection of 8-byte device descriptors

during usb device enumeration, a host may attempt to only read the
first 8 bytes of a device descriptor. Dissecting a partial device
descriptor was throwing a bounds error.

Change-Id: I09cdd356d15153afc93ee478fdd98329495a642a
Reviewed-on: https://code.wireshark.org/review/4137
Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
Sean O. Stalley 2014-09-16 14:03:03 -07:00 committed by Evan Huus
parent 4cf9e71730
commit b53405cd5a
1 changed files with 7 additions and 0 deletions

View File

@ -1466,6 +1466,13 @@ dissect_usb_device_descriptor(packet_info *pinfo, proto_tree *parent_tree,
proto_tree_add_item(tree, hf_usb_bMaxPacketSize0, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* if request was only for the first 8 bytes */
/* per 5.5.3 of USB2.0 Spec */
if (8 == usb_conv_info->usb_trans_info->setup.wLength) {
proto_item_set_len(item, offset-old_offset);
return offset;
}
/* idVendor */
proto_tree_add_item(tree, hf_usb_idVendor, tvb, offset, 2, ENC_LITTLE_ENDIAN);
vendor_id = tvb_get_letohs(tvb, offset);