diff --git a/0004-fix-out-of-bounds-array.patch b/0004-fix-out-of-bounds-array.patch new file mode 100644 index 0000000000000000000000000000000000000000..176895baa8a03f64f19f76c42467b33c2d5a471f --- /dev/null +++ b/0004-fix-out-of-bounds-array.patch @@ -0,0 +1,55 @@ +From 341bd6e8292b96ff5cf02bbaeedf447df18778aa Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Mon, 15 Jul 2024 14:03:39 +0800 +Subject: [PATCH] fix out of bounds array + +--- + thread_collector/thread_collector.cpp | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/thread_collector/thread_collector.cpp b/thread_collector/thread_collector.cpp +index f1d9cc4..cb99bba 100644 +--- a/thread_collector/thread_collector.cpp ++++ b/thread_collector/thread_collector.cpp +@@ -11,8 +11,10 @@ + ******************************************************************************/ + #include "interface.h" + #include "thread_info.h" ++#include + #include + #include ++#include + #include + #include + #include +@@ -20,7 +22,6 @@ + + char thread_name[] = "thread_collector"; + const int CYCLE_SIZE = 500; +-const int MAX_NAME_LENGTH = 20; + static DataRingBuf ring_buf; + static DataBuf data_buf; + static ThreadInfo threads[THREAD_NUM]; +@@ -60,14 +61,13 @@ static void clear_invalid_tid(int &num) { + + static ThreadInfo get_thread_info(int pid, int tid) { + std::string s_path = "/proc/" + std::to_string(pid) + "/task/" + std::to_string(tid) + "/comm"; +- FILE *s_file = fopen(s_path.c_str(), "r"); +- if (s_file == nullptr) { ++ std::ifstream input_file(s_path); ++ if (!input_file) { + return ThreadInfo{}; + } +- char name[MAX_NAME_LENGTH]; +- fscanf(s_file, "%s", name); +- fclose(s_file); +- return ThreadInfo{pid, tid, std::string(name)}; ++ std::string name; ++ input_file >> name; ++ return ThreadInfo{pid, tid, name}; + } + + static bool process_not_change(struct stat *task_stat, const std::string &task_path, int pid) { +-- +2.33.0 + diff --git a/oeAware-collector.spec b/oeAware-collector.spec index d81a27645c57edef8621838ccb508abcac6ae47f..ade0b5bb1fb72b0440d8ee4dc6d6666cee7e9004 100644 --- a/oeAware-collector.spec +++ b/oeAware-collector.spec @@ -1,6 +1,6 @@ Name: oeAware-collector Version: v1.0.2 -Release: 6 +Release: 7 Summary: %{name} provides low-overhead metrics collection capabilities, including microarchitecture, system, and kernel information. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Patch1: 0001-add-netif_rx-counting-pmu-instance.patch Patch2: 0002-reduce-thread-collector-load.patch Patch3: 0003-fix-uninitialized-PmuAttr-attr.patch +Patch4: 0004-fix-out-of-bounds-array.patch %global libkperf_name libkperf %global libkperf_tagver v1.0.4 @@ -83,6 +84,9 @@ install -b -m740 ./thread_collector/build/libthread_collector.so ${RPM_BUIL %attr(0440, root, root) %{_libdir}/oeAware-plugin/libthread_collector.so %changelog +* Mon Jul 15 2024 fly_1997 - v1.0.2-7 +- fix out of bounds array + * Fri Jul 5 2024 zhoukaiqi - v1.0.2-6 - fix uninitialized PmuAttr attr