USB: allow usb string descriptor short read

Some drivers do a probing access to the descriptor to fetch just the length field

Change-Id: Idd07a1e66800afcc838beb795594a4505ce13e82
Reviewed-on: https://code.wireshark.org/review/12250
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Thies Moeller 2015-11-29 09:45:39 +00:00 committed by Pascal Quantin
parent 1acb2816bd
commit 6952c1c54f
1 changed files with 4 additions and 2 deletions

View File

@ -1615,8 +1615,10 @@ dissect_usb_string_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree,
}
} else {
/* UTF-16 string */
proto_tree_add_item(tree, hf_usb_bString, tvb, offset, len-2, ENC_UTF_16 | ENC_LITTLE_ENDIAN);
offset += len-2;
/* handle case of host requesting only substring */
guint8 len_str = MIN(len-2, usb_trans_info->setup.wLength -2);
proto_tree_add_item(tree, hf_usb_bString, tvb, offset, len_str, ENC_UTF_16 | ENC_LITTLE_ENDIAN);
offset += len_str;
}
proto_item_set_len(item, offset-old_offset);