From 561a5963e603de6ecbad89987578e082a4ee1e11 Mon Sep 17 00:00:00 2001 From: chenkeyu Date: Thu, 6 Jun 2024 14:26:26 +0800 Subject: [PATCH] Fix wrong buffer size in thread testcases Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/I9VNWL?from=project-issue Signed-off-by: chenkeyu --- .../thread_benchmark_test/thread_benchmark_test.cpp | 4 ++-- base/test/fuzztest/thread_fuzzer/thread_fuzzer.cpp | 2 +- base/test/unittest/common/utils_thread_test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/base/test/benchmarktest/thread_benchmark_test/thread_benchmark_test.cpp b/base/test/benchmarktest/thread_benchmark_test/thread_benchmark_test.cpp index 6c93b27..90848e3 100644 --- a/base/test/benchmarktest/thread_benchmark_test/thread_benchmark_test.cpp +++ b/base/test/benchmarktest/thread_benchmark_test/thread_benchmark_test.cpp @@ -125,7 +125,7 @@ bool TestThread::Run() { BENCHMARK_LOGD("ThreadTest bool TestThread::Run is called."); priority_ = getpriority(PRIO_PROCESS, 0); - char threadName[MAX_THREAD_NAME_LEN] = {0}; + char threadName[MAX_THREAD_NAME_LEN + 1] = {0}; prctl(PR_GET_NAME, threadName, 0, 0); name_ = threadName; @@ -456,7 +456,7 @@ bool TestThread2::Run() { BENCHMARK_LOGD("ThreadTest bool TestThread2::Run is called."); priority_ = getpriority(PRIO_PROCESS, 0); - char threadName[MAX_THREAD_NAME_LEN] = {0}; + char threadName[MAX_THREAD_NAME_LEN + 1] = {0}; prctl(PR_GET_NAME, threadName, 0, 0); name_ = threadName; diff --git a/base/test/fuzztest/thread_fuzzer/thread_fuzzer.cpp b/base/test/fuzztest/thread_fuzzer/thread_fuzzer.cpp index 5bd82e0..a19acd3 100644 --- a/base/test/fuzztest/thread_fuzzer/thread_fuzzer.cpp +++ b/base/test/fuzztest/thread_fuzzer/thread_fuzzer.cpp @@ -69,7 +69,7 @@ bool TestThread::ReadyToWork() bool TestThread::Run() { priority_ = getpriority(PRIO_PROCESS, 0); - char threadName[MAX_THREAD_NAME_LEN] = {0}; + char threadName[MAX_THREAD_NAME_LEN + 1] = {0}; prctl(PR_GET_NAME, threadName, 0, 0); name_ = threadName; diff --git a/base/test/unittest/common/utils_thread_test.cpp b/base/test/unittest/common/utils_thread_test.cpp index 7da8ede..b7f7944 100644 --- a/base/test/unittest/common/utils_thread_test.cpp +++ b/base/test/unittest/common/utils_thread_test.cpp @@ -111,7 +111,7 @@ bool TestThread::ReadyToWork() bool TestThread::Run() { priority_ = getpriority(PRIO_PROCESS, 0); - char threadName[MAX_THREAD_NAME_LEN] = {0}; + char threadName[MAX_THREAD_NAME_LEN + 1] = {0}; prctl(PR_GET_NAME, threadName, 0, 0); name_ = threadName; @@ -361,7 +361,7 @@ private: bool TestThread2::Run() { priority_ = getpriority(PRIO_PROCESS, 0); - char threadName[MAX_THREAD_NAME_LEN] = {0}; + char threadName[MAX_THREAD_NAME_LEN + 1] = {0}; prctl(PR_GET_NAME, threadName, 0, 0); name_ = threadName; -- Gitee