aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-03-06 21:00:33 -0800
committerJade Lovelace <lix@jade.fyi>2024-03-06 21:00:33 -0800
commit6122bed3af3f9a46b471ba2920e728df4686dc79 (patch)
treedad8eebd9906c4b1bd0cd0cb98c37c8637a62bd5 /src/libutil
parent706f0df55b4aaf7d0441227338bd4bec7121fe67 (diff)
fix: bounds check result in getMaxCPU
Upstream-Bug: https://github.com/NixOS/nix/issues/9725 Upstream-PR: https://github.com/NixOS/nix/pull/10172 Change-Id: I2b8e8b15ee28951be98e5cbe3ccea5b9c8de5994
Diffstat (limited to 'src/libutil')
-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 6fcce5d67..691b03bb0 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")