[libunwind] [libunwind] Remove unnecessary strcpy dependency (PR #72043)
Michael Kenzel via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 12 16:06:10 PST 2023
https://github.com/michael-kenzel updated https://github.com/llvm/llvm-project/pull/72043
>From d5adc242a9c52c7de2a860489a4292b7461b6164 Mon Sep 17 00:00:00 2001
From: Michael Kenzel <michael.kenzel at gmail.com>
Date: Sun, 12 Nov 2023 02:46:15 +0100
Subject: [PATCH] [libunwind] Remove unnecessary strcpy dependency
---
libunwind/src/UnwindLevel1-gcc-ext.c | 2 +-
libunwind/test/forceunwind.pass.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libunwind/src/UnwindLevel1-gcc-ext.c b/libunwind/src/UnwindLevel1-gcc-ext.c
index d343f4e6e9cc837..32c872ffade1fd0 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 8c26551b6d0b678..db499d8bc30894e 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);
}
More information about the cfe-commits
mailing list