Skip to content

Commit

Permalink
#2302: Check buffer boundaries for fs read
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 25, 2024
1 parent 6b043c0 commit fd80626
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vt/metrics/perf_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ std::unordered_map<std::string, uint64_t> PerfData::getTaskMeasurements() {
uint64_t count = 0;

if (event_fds_[i] != -1) {
ssize_t bytesRead = read(event_fds_[i], &count, sizeof(uint64_t));
ssize_t bytesRead = read(event_fds_[i], &count, sizeof(count));

if (bytesRead == sizeof(uint64_t)) {
if (bytesRead == sizeof(count)) {
measurements[event_names_[i]] = count;
} else if (bytesRead == -1) {
vtAbort("Failed to read perf event data for: " + event_names_[i] +
". Error: " + std::strerror(errno));
} else {
vtAbort("Incomplete read for: " + event_names_[i] +
". Expected " + std::to_string(sizeof(uint64_t)) +
". Expected " + std::to_string(sizeof(count)) +
" bytes, but got " + std::to_string(bytesRead));
}
} else {
Expand Down

0 comments on commit fd80626

Please sign in to comment.