On 16/08/2026 07:50, Collin Funk wrote:
I don't think it is actually possible for this case to happen, but
checking it does no harm.
Lasse Collin mentioned it to me while we were discussing some cgroup
stuff a while ago.
diff --git a/lib/nproc.c b/lib/nproc.c
index ef86975fb1..e3dfeaa16d 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -437,10 +437,11 @@ get_cgroup2_cpu_quota (void)
is not enabled for that part of the hierarchy. */
char cpu_max_file[PATH_MAX];
- snprintf (cpu_max_file, sizeof (cpu_max_file),
- "%s%s/cpu.max", mount, cgroup);
+ int n = snprintf (cpu_max_file, sizeof (cpu_max_file),
+ "%s%s/cpu.max", mount, cgroup);
- if ((fp = fopen (cpu_max_file, "r"))
+ if (0 <= n && n < sizeof cpu_max_file
+ && (fp = fopen (cpu_max_file, "r"))
&& getline ("a_str, "a_size, fp) != -1
&& strncmp (quota_str, "max", 3) != 0)
{
LGTM.
cheers,
Padraig