From e057fb8e349d81bd3996c6d5e68719c015969bac Mon Sep 17 00:00:00 2001 From: Pierre Pebay Date: Tue, 26 Nov 2024 19:46:53 +0100 Subject: [PATCH] #2302: Add more buffer boundary check --- src/vt/metrics/perf_data.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vt/metrics/perf_data.cc b/src/vt/metrics/perf_data.cc index d3b637b422..13efad550f 100644 --- a/src/vt/metrics/perf_data.cc +++ b/src/vt/metrics/perf_data.cc @@ -146,6 +146,11 @@ std::unordered_map PerfData::getTaskMeasurements() { uint64_t count = 0; if (event_fds_[i] != -1) { + if (sizeof(count) != sizeof(uint64_t)) { + vtAbort("Buffer size mismatch: expected " + std::to_string(sizeof(uint64_t)) + + " bytes, but got " + std::to_string(sizeof(count))); + } + ssize_t bytesRead = read(event_fds_[i], &count, sizeof(count)); if (bytesRead == sizeof(count)) {