File get-nprocs-cpu-online-parsing.patch of Package glibc.18276

From b5eeca8cfd9d0fd92b5633a88901d9ff27f2b496 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@linux-m68k.org>
Date: Tue, 8 Dec 2020 19:17:41 +0100
Subject: [PATCH] Fix parsing of /sys/devices/system/cpu/online (bug 25859)

The file contains comma-separated ranges, not spaces.
---
 sysdeps/unix/sysv/linux/getsysstats.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: glibc-2.26/sysdeps/unix/sysv/linux/getsysstats.c
===================================================================
--- glibc-2.26.orig/sysdeps/unix/sysv/linux/getsysstats.c
+++ glibc-2.26/sysdeps/unix/sysv/linux/getsysstats.c
@@ -143,6 +143,7 @@ __get_nprocs (void)
   char *re = buffer_end;
 
   const int flags = O_RDONLY | O_CLOEXEC;
+  /* This file contains comma-separated ranges.  */
   int fd = open_not_cancel_2 ("/sys/devices/system/cpu/online", flags);
   char *l;
   int result = 0;
@@ -175,10 +176,10 @@ __get_nprocs (void)
 	    result += m - n + 1;
 
 	    l = endp;
-	    while (l < re && isspace (*l))
+	    if (l < re && *l == ',')
 	      ++l;
 	  }
-	while (l < re);
+	while (l < re && *l != '\n');
 
       close_not_cancel_no_status (fd);
openSUSE Build Service is sponsored by