|
From: openocd-gerrit <ope...@us...> - 2026-09-08 08:14:45
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 71576b70c75d17dc7b613a310b7797cd9b5dcfaa (commit)
from 046c040cb0012e2f908bb11009b39bf502cff6f3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 71576b70c75d17dc7b613a310b7797cd9b5dcfaa
Author: Tomas Vanek <va...@fb...>
Date: Fri Aug 21 10:26:49 2026 +0200
jtag/drivers/cmsis_dap: add adapter info response size checks
Check the DAP_Info Command response length byte and return error
if info payload would overflow over response end.
Use the length byte to limit the number of character in the returned
info string to avoid problems in case the string is not properly
null terminated (e.g. when the adapter firmware does not conform
to CMSIS-DAP spec or accidentally getting the response of another
CMSIS-DAP command).
Reported-by: Antonio Borneo <bor...@gm...>
Change-Id: I4ee151b064b870def3f6b88abd059e578716db6e
Signed-off-by: Tomas Vanek <va...@fb...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9857
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c
index d93ef51a9..d3f32c98c 100644
--- a/src/jtag/drivers/cmsis_dap.c
+++ b/src/jtag/drivers/cmsis_dap.c
@@ -479,6 +479,12 @@ static int cmsis_dap_cmd_dap_info(uint8_t info, uint8_t **data)
return ERROR_JTAG_DEVICE_ERROR;
}
+ unsigned int info_size = cmsis_dap_handle->response[1];
+ if (2 + info_size > cmsis_dap_handle->response_size) {
+ LOG_ERROR("CMSIS-DAP CMD_INFO payload (size %u) does not fit into response (size %u)",
+ info_size, cmsis_dap_handle->response_size);
+ return ERROR_JTAG_DEVICE_ERROR;
+ }
*data = &cmsis_dap_handle->response[1];
return ERROR_OK;
@@ -1163,7 +1169,7 @@ static int cmsis_dap_get_serial_info(void)
return retval;
if (data[0]) /* strlen */
- LOG_INFO("CMSIS-DAP: Serial# = %s", &data[1]);
+ LOG_INFO("CMSIS-DAP: Serial# = %.*s", data[0], &data[1]);
return ERROR_OK;
}
@@ -1178,7 +1184,7 @@ static int cmsis_dap_get_version_info(void)
return retval;
if (data[0]) /* strlen */
- LOG_INFO("CMSIS-DAP: FW Version = %s", &data[1]);
+ LOG_INFO("CMSIS-DAP: FW Version = %.*s", data[0], &data[1]);
return ERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
src/jtag/drivers/cmsis_dap.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|