Skip to content

Commit 894ed64

Browse files
authored
fix: int overflow in get_jiffies (#57)
1 parent cf9fa44 commit 894ed64

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/linux/utils/filesystem.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ Jiffies get_jiffies(int index) {
7575
std::istringstream iss(line);
7676
std::vector<std::string> results(std::istream_iterator<std::string>{iss}, std::istream_iterator<std::string>());
7777

78-
const int jiffies_0 = std::stoi(results[1]);
79-
const int jiffies_1 = std::stoi(results[2]);
80-
const int jiffies_2 = std::stoi(results[3]);
81-
const int jiffies_3 = std::stoi(results[4]);
82-
const int jiffies_4 = std::stoi(results[5]);
83-
const int jiffies_5 = std::stoi(results[6]);
84-
const int jiffies_6 = std::stoi(results[7]);
85-
const int jiffies_7 = std::stoi(results[8]);
86-
const int jiffies_8 = std::stoi(results[9]);
87-
const int jiffies_9 = std::stoi(results[10]);
78+
const int64_t jiffies_0 = std::stol(results[1]);
79+
const int64_t jiffies_1 = std::stol(results[2]);
80+
const int64_t jiffies_2 = std::stol(results[3]);
81+
const int64_t jiffies_3 = std::stol(results[4]);
82+
const int64_t jiffies_4 = std::stol(results[5]);
83+
const int64_t jiffies_5 = std::stol(results[6]);
84+
const int64_t jiffies_6 = std::stol(results[7]);
85+
const int64_t jiffies_7 = std::stol(results[8]);
86+
const int64_t jiffies_8 = std::stol(results[9]);
87+
const int64_t jiffies_9 = std::stol(results[10]);
8888

8989
int64_t all = jiffies_0 + jiffies_1 + jiffies_2 + jiffies_3 + jiffies_4 + jiffies_5 + jiffies_6 + jiffies_7 +
9090
jiffies_8 + jiffies_9;

0 commit comments

Comments
 (0)