Skip to content

Commit

Permalink
hosted/cmsis_dap: Limit the max packet size to 512 bytes to not overf…
Browse files Browse the repository at this point in the history
…low any buffers anywhere
  • Loading branch information
dragonmux committed Nov 15, 2024
1 parent cd09b34 commit bd6188b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/platforms/hosted/cmsis_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ static bool dap_init_hid(void)

/*
* Base the report length information for the device on the max packet length from its descriptors.
* Add 1 to account for HIDAPI's need to prefix with a report type byte.
* Add 1 to account for HIDAPI's need to prefix with a report type byte. Limit to at most 512 bytes.
*/
dap_packet_size = bmda_probe_info.max_packet_length + 1U;
dap_packet_size = MIN(bmda_probe_info.max_packet_length + 1U, 512U);

/* Handle the NXP LPC11U3x CMSIS-DAP v1.0.7 implementation needing a 64 byte report length */
if (bmda_probe_info.vid == 0x1fc9U && bmda_probe_info.pid == 0x0132U)
Expand Down

0 comments on commit bd6188b

Please sign in to comment.