This is an automated email from the ASF dual-hosted git repository.
archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3e6649856b Fix Overlap Handling in sim_copyfullstate to Prevent
Undefined Behavior
3e6649856b is described below
commit 3e6649856bd36f5508a4b17b423e562e4e3572e7
Author: Ritvik <[email protected]>
AuthorDate: Sat Jan 4 12:16:42 2025 -0500
Fix Overlap Handling in sim_copyfullstate to Prevent Undefined Behavior
---
arch/sim/src/sim/sim_copyfullstate.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/sim/src/sim/sim_copyfullstate.c
b/arch/sim/src/sim/sim_copyfullstate.c
index 64a28be273..1c773e93c9 100644
--- a/arch/sim/src/sim/sim_copyfullstate.c
+++ b/arch/sim/src/sim/sim_copyfullstate.c
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <stdint.h>
+#include <string.h>
#include <arch/irq.h>
#include "sim_internal.h"
@@ -45,8 +46,6 @@
void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src)
{
- int i;
-
/* In the sim model, the state is copied from the stack to the TCB,
* but only a reference is passed to get the state from the TCB. So the
* following check avoids copying the TCB save area onto itself:
@@ -54,9 +53,6 @@ void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src)
if (src != dest)
{
- for (i = 0; i < XCPTCONTEXT_REGS; i++)
- {
- *dest++ = *src++;
- }
+ memmove(dest, src, XCPTCONTEXT_REGS * sizeof(xcpt_reg_t));
}
}