aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-03-06 22:24:51 -0700
committerGerrit Code Review <gerrit@lix>2024-03-06 22:24:51 -0700
commit0d9a043f4365100c5b451b6476edb2b9ab09e19b (patch)
tree2573a380b9d7e42f74521b703d8327b7ed1f4197 /src/libutil/util.cc
parentf10e673272425fd6f7b6d93a8f62bd7ff378e8c8 (diff)
parent6122bed3af3f9a46b471ba2920e728df4686dc79 (diff)
Merge "fix: bounds check result in getMaxCPU" into main
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 51cda9da4..bbd57434d 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -796,6 +796,11 @@ unsigned int getMaxCPU()
auto cpuMax = readFile(cpuFile);
auto cpuMaxParts = tokenizeString<std::vector<std::string>>(cpuMax, " \n");
+
+ if (cpuMaxParts.size() != 2) {
+ return 0;
+ }
+
auto quota = cpuMaxParts[0];
auto period = cpuMaxParts[1];
if (quota != "max")