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
This commit is contained in:
jade 2024-03-06 21:00:33 -08:00
parent 706f0df55b
commit 6122bed3af

View file

@ -796,6 +796,11 @@ unsigned int getMaxCPU()
auto cpuMax = readFile(cpuFile); auto cpuMax = readFile(cpuFile);
auto cpuMaxParts = tokenizeString<std::vector<std::string>>(cpuMax, " \n"); auto cpuMaxParts = tokenizeString<std::vector<std::string>>(cpuMax, " \n");
if (cpuMaxParts.size() != 2) {
return 0;
}
auto quota = cpuMaxParts[0]; auto quota = cpuMaxParts[0];
auto period = cpuMaxParts[1]; auto period = cpuMaxParts[1];
if (quota != "max") if (quota != "max")