From 9c64a09c709e3f995d7f24cdd5a69435c08488fc Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Wed, 6 Mar 2024 20:52:58 -0800 Subject: [PATCH] fix: bounds check result in getMaxCPU Fixes https://github.com/NixOS/nix/issues/9725 --- src/libutil/current-process.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libutil/current-process.cc b/src/libutil/current-process.cc index 47aa137d8..f80f43ef0 100644 --- a/src/libutil/current-process.cc +++ b/src/libutil/current-process.cc @@ -38,6 +38,11 @@ unsigned int getMaxCPU() auto cpuMax = readFile(cpuFile); auto cpuMaxParts = tokenizeString>(cpuMax, " \n"); + + if (cpuMaxParts.size() != 2) { + return 0; + } + auto quota = cpuMaxParts[0]; auto period = cpuMaxParts[1]; if (quota != "max")