94084c
commit 05c83ccaf50aef2dd30d92cbb814383f6bddea2c
94084c
Author: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
94084c
Date:   Tue Feb 1 22:39:02 2022 +0000
94084c
94084c
    linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]
94084c
    
94084c
    Pass the actual number of bytes returned by the kernel.
94084c
    
94084c
    Fixes: 33099d72e41c ("linux: Simplify get_nprocs")
94084c
    Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
94084c
    
94084c
    (cherry picked from commit 97ba273b505763325efd802dc3a9562dbba79579)
94084c
94084c
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
94084c
index 7fc6521942e87293..7babd947aa902e77 100644
94084c
--- a/sysdeps/unix/sysv/linux/getsysstats.c
94084c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
94084c
@@ -45,7 +45,7 @@ __get_nprocs_sched (void)
94084c
   int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
94084c
 				 cpu_bits);
94084c
   if (r > 0)
94084c
-    return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
94084c
+    return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits);
94084c
   else if (r == -EINVAL)
94084c
     /* The input buffer is still not enough to store the number of cpus.  This
94084c
        is an arbitrary values assuming such systems should be rare and there