|
From: openocd-gerrit <ope...@us...> - 2026-04-06 16:23:52
|
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 231aa88ee5170f28c3a6f9c2bd3055ba7f242c99 (commit)
via 49e75c74d5572d49f575603ceae2b65ef9b08a81 (commit)
from bd17a59fd14e72a36930af4ab87d3f7b74887206 (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 231aa88ee5170f28c3a6f9c2bd3055ba7f242c99
Author: Mark O'Donovan <sh...@po...>
Date: Mon Mar 9 21:24:32 2026 +0000
target/arm_simulator: fix undefined behaviour
Shifting 32 bit unsigned variables by 32 bits is undefined behaviour
Change-Id: I846619a522c747f9c3b11a814a1864d1d51cfe87
Signed-off-by: Mark O'Donovan <sh...@po...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9502
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/target/arm_simulator.c b/src/target/arm_simulator.c
index e9f667116..8a87e4412 100644
--- a/src/target/arm_simulator.c
+++ b/src/target/arm_simulator.c
@@ -27,25 +27,31 @@ static uint32_t arm_shift(uint8_t shift, uint32_t rm,
shift_amount &= 0xff;
if (shift == 0x0) { /* LSL */
- if ((shift_amount > 0) && (shift_amount <= 32)) {
+ if (shift_amount > 0 && shift_amount < 32) {
return_value = rm << shift_amount;
*carry = rm >> (32 - shift_amount);
+ } else if (shift_amount == 32) {
+ return_value = 0x0;
+ *carry = rm & 0x1;
} else if (shift_amount > 32) {
return_value = 0x0;
*carry = 0x0;
} else /* (shift_amount == 0) */
return_value = rm;
} else if (shift == 0x1) { /* LSR */
- if ((shift_amount > 0) && (shift_amount <= 32)) {
+ if (shift_amount > 0 && shift_amount < 32) {
return_value = rm >> shift_amount;
*carry = (rm >> (shift_amount - 1)) & 1;
+ } else if (shift_amount == 32) {
+ return_value = 0x0;
+ *carry = (rm >> 31) & 0x1;
} else if (shift_amount > 32) {
return_value = 0x0;
*carry = 0x0;
} else /* (shift_amount == 0) */
return_value = rm;
} else if (shift == 0x2) { /* ASR */
- if ((shift_amount > 0) && (shift_amount <= 32)) {
+ if (shift_amount > 0 && shift_amount < 32) {
/* C right shifts of unsigned values are guaranteed to
* be logical (shift in zeroes); simulate an arithmetic
* shift (shift in signed-bit) by adding the sign bit
@@ -54,7 +60,7 @@ static uint32_t arm_shift(uint8_t shift, uint32_t rm,
return_value = rm >> shift_amount;
if (rm & 0x80000000)
return_value |= 0xffffffff << (32 - shift_amount);
- } else if (shift_amount > 32) {
+ } else if (shift_amount >= 32) {
if (rm & 0x80000000) {
return_value = 0xffffffff;
*carry = 0x1;
commit 49e75c74d5572d49f575603ceae2b65ef9b08a81
Author: Mark O'Donovan <sh...@po...>
Date: Tue Feb 24 20:37:06 2026 +0000
rtos/hwthread: move pointer deref after NULL check
Move pointer deref after NULL check.
Found by cppcheck.
Change-Id: I41b20a0598da83b6d7e353042b6f69e7a58706fc
Signed-off-by: Mark O'Donovan <sh...@po...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9501
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c
index d422fac53..9367f70af 100644
--- a/src/rtos/hwthread.c
+++ b/src/rtos/hwthread.c
@@ -94,12 +94,13 @@ static int hwthread_update_threads(struct rtos *rtos)
struct target_list *head;
struct target *target;
int64_t current_thread = 0;
- int64_t current_threadid = rtos->current_threadid; /* thread selected by GDB */
+ int64_t current_threadid;
enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
if (!rtos)
return -1;
+ current_threadid = rtos->current_threadid; /* thread selected by GDB */
target = rtos->target;
/* wipe out previous thread details if any */
-----------------------------------------------------------------------
Summary of changes:
src/rtos/hwthread.c | 3 ++-
src/target/arm_simulator.c | 14 ++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|