Merge "Correct off-by-one error in SetThreadName" am: bb1686a6ac am: 8da7bd5d2a am: d497310b93

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2019395

Change-Id: Ibb0049e0a53d7d2c16345221d205b9c5c97d1cef
This commit is contained in:
Hans Boehm
2022-03-10 01:42:14 +00:00
committed by Automerger Merge Worker

View File

@@ -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));