Commit 3dbbc28b authored by Simon Giesecke's avatar Simon Giesecke

Problem: use of unsafe strcpy

Solution: use memcpy with known size instead
parent 334e837b
...@@ -411,6 +411,7 @@ void zmq::print_backtrace (void) ...@@ -411,6 +411,7 @@ void zmq::print_backtrace (void)
while (unw_step (&cursor) > 0) { while (unw_step (&cursor) > 0) {
unw_word_t offset; unw_word_t offset;
unw_proc_info_t p_info; unw_proc_info_t p_info;
static const char unknown[] = "?";
const char *file_name; const char *file_name;
char *demangled_name; char *demangled_name;
char func_name[256] = ""; char func_name[256] = "";
...@@ -422,14 +423,14 @@ void zmq::print_backtrace (void) ...@@ -422,14 +423,14 @@ void zmq::print_backtrace (void)
rc = unw_get_proc_name (&cursor, func_name, 256, &offset); rc = unw_get_proc_name (&cursor, func_name, 256, &offset);
if (rc == -UNW_ENOINFO) if (rc == -UNW_ENOINFO)
strcpy (func_name, "?"); memcpy (func_name, unknown, sizeof unknown);
addr = (void *) (p_info.start_ip + offset); addr = (void *) (p_info.start_ip + offset);
if (dladdr (addr, &dl_info) && dl_info.dli_fname) if (dladdr (addr, &dl_info) && dl_info.dli_fname)
file_name = dl_info.dli_fname; file_name = dl_info.dli_fname;
else else
file_name = "?"; file_name = unknown;
demangled_name = abi::__cxa_demangle (func_name, NULL, NULL, &rc); demangled_name = abi::__cxa_demangle (func_name, NULL, NULL, &rc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment