diff options
| author | dxbjavid <[email protected]> | 2026-06-15 10:25:51 +0530 |
|---|---|---|
| committer | dxbjavid <[email protected]> | 2026-06-15 10:25:51 +0530 |
| commit | 9f8812f81bdd323399abd6e18c2567fed3efebc5 (patch) | |
| tree | b489f59c1de0b524f8ceec3cf7f5aba33bdd97df /src/class | |
| parent | 85047e1777f5c20b7a936aa905c746125d3ed066 (diff) | |
zero-extend usage page before copying shorter payload
Diffstat (limited to 'src/class')
| -rw-r--r-- | src/class/hid/hid_host.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index bd419c72d..29bcae99f 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -742,7 +742,12 @@ uint8_t tuh_hid_parse_report_descriptor(tuh_hid_report_info_t* report_info_arr, switch (tag) { case RI_GLOBAL_USAGE_PAGE: // only take in account the "usage page" before REPORT ID - if (ri_collection_depth == 0) memcpy(&info->usage_page, desc_report, TU_MIN(size, sizeof(info->usage_page))); + if (ri_collection_depth == 0) { + // zero-extend: a shorter payload must not leave a stale high byte + // from a previous usage page item in the same report + info->usage_page = 0; + memcpy(&info->usage_page, desc_report, TU_MIN(size, sizeof(info->usage_page))); + } break; case RI_GLOBAL_LOGICAL_MIN: break; |
