@@ -453,14 +453,18 @@ static int cps_fix_report_desc(HIDDevice_t *pDev, HIDDesc_t *pDesc_arg) {
453
453
&& input_pData -> Size > 1
454
454
&& input_pData -> Size <= sizeof (long )* 8
455
455
) {
456
- /* Note: values are signed, so limit by
457
- * 2^(size-1)-1, e.g. for "size==16" the
458
- * limit should be "2^15 - 1 = 32767";
456
+ /* Note: usually values are signed, but
457
+ * here we are about compensating for
458
+ * poorly encoded maximums, so limit by
459
+ * 2^(size)-1, e.g. for "size==16" the
460
+ * limit should be "2^16 - 1 = 65535";
459
461
* note that in HIDParse() we likely
460
462
* set 65535 here in that case. See
461
- * also comments there (hidparser.c).
463
+ * also comments there (hidparser.c)
464
+ * discussing signed/unsigned nuances.
462
465
*/
463
- long sizeMax = (1L << (input_pData -> Size - 1 )) - 1 ;
466
+ /* long sizeMax = (1L << (input_pData->Size - 1)) - 1; */
467
+ long sizeMax = (1L << (input_pData -> Size )) - 1 ;
464
468
if (input_logmax > sizeMax ) {
465
469
input_logmax = sizeMax ;
466
470
}
@@ -471,7 +475,8 @@ static int cps_fix_report_desc(HIDDevice_t *pDev, HIDDesc_t *pDesc_arg) {
471
475
&& output_pData -> Size <= sizeof (long )* 8
472
476
) {
473
477
/* See comment above */
474
- long sizeMax = (1L << (output_pData -> Size - 1 )) - 1 ;
478
+ /* long sizeMax = (1L << (output_pData->Size - 1)) - 1; */
479
+ long sizeMax = (1L << (output_pData -> Size )) - 1 ;
475
480
if (output_logmax > sizeMax ) {
476
481
output_logmax = sizeMax ;
477
482
}
0 commit comments