tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit e2a7d08aa7c51fa903d5294628612a13b4c0d6e0
parent 190386f1c44462fbef568ca9e3c1c997dbebcf12
Author: teor <teor@torproject.org>
Date:   Fri, 30 Aug 2019 21:12:52 +1000

backtrace: Always set a backtrace Tor version

We want to report the tor version, even on platforms that don't have
backtrace support (like Android).

This commit stores the backtrace Tor version, regardless of USE_BACKTRACE.

Preparation for 31571.

Diffstat:
Msrc/lib/err/backtrace.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c @@ -68,10 +68,10 @@ // Redundant with util.h, but doing it here so we can avoid that dependency. #define raw_free free -#ifdef USE_BACKTRACE /** Version of Tor to report in backtrace messages. */ static char bt_version[128] = ""; +#ifdef USE_BACKTRACE /** Largest stack depth to try to dump. */ #define MAX_DEPTH 256 /** Static allocation of stack to dump. This is static so we avoid stack @@ -193,15 +193,12 @@ dump_stack_symbols_to_error_fds(void) /** Install signal handlers as needed so that when we crash, we produce a * useful stack trace. Return 0 on success, -errno on failure. */ static int -install_bt_handler(const char *software) +install_bt_handler(void) { int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; int i, rv=0; - strncpy(bt_version, software, sizeof(bt_version) - 1); - bt_version[sizeof(bt_version) - 1] = 0; - struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -247,9 +244,8 @@ log_backtrace_impl(int severity, int domain, const char *msg, } static int -install_bt_handler(const char *software) +install_bt_handler(void) { - (void) software; return 0; } @@ -274,7 +270,10 @@ configure_backtrace_handler(const char *tor_version) snprintf(version, sizeof(version), "Tor %s", tor_version); } - return install_bt_handler(version); + strncpy(bt_version, version, sizeof(bt_version) - 1); + bt_version[sizeof(bt_version) - 1] = 0; + + return install_bt_handler(); } /** Perform end-of-process cleanup for code that generates error messages on