btstack_hid_parser: return false on parsing error in btstack_hid_get_report_size_for_id

This commit is contained in:
Matthias Ringwald 2024-03-07 12:41:56 +01:00
parent 76fa2448e1
commit 3a1d529668
2 changed files with 5 additions and 1 deletions

View File

@ -443,7 +443,10 @@ int btstack_hid_get_report_size_for_id(int report_id, hid_report_type_t report_t
while (hid_descriptor_len){
int valid_report_type = 0;
hid_descriptor_item_t item;
btstack_hid_parse_descriptor_item(&item, hid_descriptor, hid_descriptor_len);
bool ok = btstack_hid_parse_descriptor_item(&item, hid_descriptor, hid_descriptor_len);
if (ok == false) {
return 0;
}
switch (item.item_type){
case Global:
switch ((GlobalItemTag)item.item_tag){

View File

@ -194,6 +194,7 @@ bool btstack_hid_parse_descriptor_item(hid_descriptor_item_t * item, const uint8
* @param report_type
* @param hid_descriptor_len
* @param hid_descriptor
* @return report size in bytes or 0 on parsing error
*/
int btstack_hid_get_report_size_for_id(int report_id, hid_report_type_t report_type, uint16_t hid_descriptor_len, const uint8_t * hid_descriptor);