summaryrefslogtreecommitdiff
path: root/debuggerd/handler/debuggerd_handler.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-02-14 21:03:23 -0800
committerJosh Gao <jmgao@google.com>2017-02-15 12:24:09 -0800
commit60515bf9f1b9eb222ed5fff274a8917ed9548add (patch)
treed87f38e2a7d508713dcf5b3888cb67679226404d /debuggerd/handler/debuggerd_handler.cpp
parentaf776fd518df4f677bf8c3f4a8d22d23a3479181 (diff)
debuggerd_handler: don't use snprintf in handler.
snprintf isn't safe to call in the linker after initialization, because it uses MB_CUR_MAX which is implemented via pthread_getspecific, which uses TLS slots shared with libc. If the TLS slots are assigned in a different order between libc.so and the linker, MB_CUR_MAX will evaluate to an incorrect value, and lead to snprintf doing bad things. Switch to __libc_format_buffer. Bug: http://b/35367169 Test: debuggerd -b `pidof zygote` Change-Id: I9d315cf63e5f3fd2f4545d6e3f707cdbe94ec606
Diffstat (limited to 'debuggerd/handler/debuggerd_handler.cpp')
-rw-r--r--debuggerd/handler/debuggerd_handler.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index a5de83a29..b1dc01aca 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -81,7 +81,7 @@ static void __noreturn __printflike(1, 2) fatal_errno(const char* fmt, ...) {
va_start(args, fmt);
char buf[4096];
- vsnprintf(buf, sizeof(buf), fmt, args);
+ __libc_format_buffer_va_list(buf, sizeof(buf), fmt, args);
fatal("%s: %s", buf, strerror(err));
}
@@ -256,8 +256,9 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
char main_tid[10];
char pseudothread_tid[10];
- snprintf(main_tid, sizeof(main_tid), "%d", thread_info->crashing_tid);
- snprintf(pseudothread_tid, sizeof(pseudothread_tid), "%d", thread_info->pseudothread_tid);
+ __libc_format_buffer(main_tid, sizeof(main_tid), "%d", thread_info->crashing_tid);
+ __libc_format_buffer(pseudothread_tid, sizeof(pseudothread_tid), "%d", thread_info->pseudothread_tid);
+
execl(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, nullptr);
fatal_errno("exec failed");