From edd99c3a7f22e2cb0aab16ec64647a16e9b06359 Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Wed, 9 Mar 2022 11:46:04 -0800 Subject: Correct off-by-one error in SetThreadName This truncated thread names to one fewer character than was intended. Test: Build and boot AOSP. Change-Id: I38f56b473e70e1baf0b810944a9ccd275f272bef --- core/jni/com_android_internal_os_Zygote.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 597167026d19..5023927c2560 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -895,7 +895,7 @@ void SetThreadName(const std::string& thread_name) { // pthread_setname_np fails rather than truncating long strings. char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded into bionic - strlcpy(buf, name_start_ptr, sizeof(buf) - 1); + strlcpy(buf, name_start_ptr, sizeof(buf)); errno = pthread_setname_np(pthread_self(), buf); if (errno != 0) { ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno)); -- cgit v1.2.3-59-g8ed1b