aboutsummaryrefslogtreecommitdiff
path: root/libunwind
diff options
context:
space:
mode:
authorMichael Kenzel <15786918+michael-kenzel@users.noreply.github.com>2023-11-16 00:41:53 +0100
committerGitHub <noreply@github.com>2023-11-15 18:41:53 -0500
commitb7a249d26fe61432050df470d23bdea417fda574 (patch)
treebc1f86f468fe6f2a592849021c660acc3b1e1199 /libunwind
parent917a550f4d7aaa79b04ed8998a45695a29f0f748 (diff)
downloadllvm-b7a249d26fe61432050df470d23bdea417fda574.zip
llvm-b7a249d26fe61432050df470d23bdea417fda574.tar.gz
llvm-b7a249d26fe61432050df470d23bdea417fda574.tar.bz2
[libunwind] Remove unnecessary strcpy dependency (#72043)
libunwind uses a minimal set of necessary standard library functions, basically just `memset` and `memcpy`. There is a single use of `strcpy` to copy the bytes `"CLNGUNW"` into a `uint64_t` object. This is both an arguably odd use of the `strcpy` function as well as it unnecessarily widens the set of library functions that must be available to build libunwind, which can be an obstacle in baremetal scenarios. This change simply replaces this one `strcpy` with the more fundamental `memcpy`.
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/src/UnwindLevel1-gcc-ext.c2
-rw-r--r--libunwind/test/forceunwind.pass.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/libunwind/src/UnwindLevel1-gcc-ext.c b/libunwind/src/UnwindLevel1-gcc-ext.c
index d343f4e..32c872f 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -143,7 +143,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
// Create a mock exception object for force unwinding.
_Unwind_Exception ex;
memset(&ex, '\0', sizeof(ex));
- strcpy((char *)&ex.exception_class, "CLNGUNW");
+ memcpy(&ex.exception_class, "CLNGUNW", sizeof(ex.exception_class));
#endif
// walk each frame
diff --git a/libunwind/test/forceunwind.pass.cpp b/libunwind/test/forceunwind.pass.cpp
index 8c26551..db499d8 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -61,7 +61,7 @@ __attribute__((noinline)) void foo() {
#if defined(_LIBUNWIND_ARM_EHABI)
// Create a mock exception object.
memset(e, '\0', sizeof(*e));
- strcpy(reinterpret_cast<char *>(&e->exception_class), "CLNGUNW");
+ memcpy(&e->exception_class, "CLNGUNW", sizeof(e->exception_class));
#endif
_Unwind_ForcedUnwind(e, stop, (void *)&foo);
}