Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_hidh_integrity_check_bug_v5.2' into 'release…
Browse files Browse the repository at this point in the history
…/v5.2'

fix(esp_hid): Loose the check of input report length to be more compatible[backport 5.2]

See merge request espressif/esp-idf!32721
  • Loading branch information
wmy-espressif committed Aug 9, 2024
2 parents 05446f6 + 900f366 commit 876eaf8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/esp_hid/src/esp_hidh.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -518,7 +518,7 @@ esp_err_t esp_hidh_dev_report_maps_get(esp_hidh_dev_t *dev, size_t *num_maps, es
* */

/**
* `lock_devices()` only protect the devices list, this mutex protect the single deivce instance.
* `lock_devices()` only protect the devices list, this mutex protect the single device instance.
*/
inline void esp_hidh_dev_lock(esp_hidh_dev_t *dev)
{
Expand Down Expand Up @@ -637,8 +637,13 @@ esp_hidh_dev_report_t *esp_hidh_dev_get_input_report_by_proto_and_data(esp_hidh_
}
r = dev->reports;
while (r) {
if (r->value_len == len - 1 && r->report_id == *data && (r->report_type & ESP_HID_REPORT_TYPE_INPUT) &&
r->protocol_mode == protocol_mode) {
/**
* @note For some HID device, the input report length may exceed the length which is declared in HID
* descriptor, like Logitech K380 keyboard. So loose the check condition from `r->value_len == len - 1` to
* `r->value_len <= len - 1`.
*/
if (r->value_len <= len - 1 && r->report_id == *data && (r->report_type & ESP_HID_REPORT_TYPE_INPUT) &&
r->protocol_mode == protocol_mode) {
*has_report_id = true;
break;
}
Expand Down

0 comments on commit 876eaf8

Please sign in to comment.