From: openocd-gerrit <ope...@us...> - 2024-10-05 15:38:53
|
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 8edfdb02ed1fd73568ef9e9522634e65791dbd69 (commit) from 1173473f662bbdf6d1499654568256257eee6cdd (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 8edfdb02ed1fd73568ef9e9522634e65791dbd69 Author: Antonio Borneo <bor...@gm...> Date: Sun Sep 1 14:45:36 2024 +0200 rtos: chibios: fix version display The field 'struct chibios_chdebug::ch_version' is 16 bits wide, so using le_to_h_u32() and be_to_h_u32() overflows in the following fields of the struct. Restrict the endianness conversion to 16 bits and use the target endianness dependent target_buffer_get_u16(). Convert the 'struct chibios_chdebug::ch_version' to an array of uint8_t. Change-Id: Iaa80e9cb1a65c27512919398b8ffbf14e5c240cd Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8473 Tested-by: jenkins diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c index c1e4e8419..f4ee33a49 100644 --- a/src/rtos/chibios.c +++ b/src/rtos/chibios.c @@ -31,7 +31,7 @@ struct chibios_chdebug { char ch_identifier[4]; /**< @brief Always set to "main". */ uint8_t ch_zero; /**< @brief Must be zero. */ uint8_t ch_size; /**< @brief Size of this structure. */ - uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */ + uint8_t ch_version[2]; /**< @brief Encoded ChibiOS/RT version. */ uint8_t ch_ptrsize; /**< @brief Size of a pointer. */ uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */ uint8_t ch_threadsize; /**< @brief Size of a @p Thread struct. */ @@ -171,13 +171,7 @@ static int chibios_update_memory_signature(struct rtos *rtos) " expected. Assuming compatibility..."); } - /* Convert endianness of version field */ - const uint8_t *versiontarget = (const uint8_t *) - &signature->ch_version; - signature->ch_version = rtos->target->endianness == TARGET_LITTLE_ENDIAN ? - le_to_h_u32(versiontarget) : be_to_h_u32(versiontarget); - - const uint16_t ch_version = signature->ch_version; + const uint16_t ch_version = target_buffer_get_u16(rtos->target, signature->ch_version); LOG_INFO("Successfully loaded memory map of ChibiOS/RT target " "running version %i.%i.%i", GET_CH_KERNEL_MAJOR(ch_version), GET_CH_KERNEL_MINOR(ch_version), GET_CH_KERNEL_PATCH(ch_version)); ----------------------------------------------------------------------- Summary of changes: src/rtos/chibios.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) hooks/post-receive -- Main OpenOCD repository |