From f46b6d1f88392c32e791c00640fa7c3e511aa518 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Mon, 11 Nov 2024 08:26:45 +0000 Subject: [PATCH] hosted/cmsis_dap: Limit the max packet size to 512 bytes to not overflow any buffers anywhere --- src/platforms/hosted/cmsis_dap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/hosted/cmsis_dap.c b/src/platforms/hosted/cmsis_dap.c index 30d053e5e31..6ab7decdab6 100644 --- a/src/platforms/hosted/cmsis_dap.c +++ b/src/platforms/hosted/cmsis_dap.c @@ -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)