forked from osmocom/wireshark
USB HID: Usage Minimum and Usage Maximum are inclusive
Usage Minimum and Usage Maximum are an inclusive, closed interval. This fixes an fencepost error where the Usage Maximum value was not being included as a possible value in the bitfield. Related to #17014
This commit is contained in:
parent
6a6f58c9aa
commit
5ca608f519
|
@ -6,6 +6,10 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
/* See specification at
|
||||
* https://www.usb.org/sites/default/files/documents/hid1_11.pdf
|
||||
* https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -3488,13 +3492,15 @@ parse_report_descriptor(report_descriptor_t *rdesc)
|
|||
return FALSE;
|
||||
|
||||
usage_max = hid_unpack_value(data, i, size);
|
||||
if (usage_min >= usage_max) {
|
||||
if (usage_min > usage_max) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
wmem_array_grow(field.usages, usage_max - usage_min);
|
||||
for (guint32 j = usage_min; j < usage_max; j++)
|
||||
/* min and max are inclusive */
|
||||
wmem_array_grow(field.usages, usage_max - usage_min + 1);
|
||||
for (guint32 j = usage_min; j <= usage_max; j++) {
|
||||
wmem_array_append_one(field.usages, j);
|
||||
}
|
||||
|
||||
defined ^= HID_USAGE_MIN;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue