From patchwork Wed Dec 9 14:09:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 41346 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F4BD3861843; Wed, 9 Dec 2020 14:09:43 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id BFFC03858C27 for ; Wed, 9 Dec 2020 14:09:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BFFC03858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=whitebox@nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Crf7R3zNWz1s1JC for ; Wed, 9 Dec 2020 15:09:39 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Crf7R0H1Yz1tlRr for ; Wed, 9 Dec 2020 15:09:39 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ihN6CyNxiY5g for ; Wed, 9 Dec 2020 15:09:38 +0100 (CET) X-Auth-Info: 0zBNg+LiOxwipOg7lW7ZuEaByrcsjNYEKXg70yWPBHiSLIZOzJq9wxBqV+QHIOxx Received: from igel.home (ppp-46-244-177-104.dynamic.mnet-online.de [46.244.177.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Wed, 9 Dec 2020 15:09:38 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 420612C32FF; Wed, 9 Dec 2020 15:09:37 +0100 (CET) From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Fix parsing of /sys/devices/system/cpu/online (bug 27038) X-Yow: I'm RELIGIOUS!! I love a man with a HAIRPIECE!! Equip me with MISSILES!! Date: Wed, 09 Dec 2020 15:09:37 +0100 Message-ID: <87im9b3wbi.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The file contains comma-separated ranges, not spaces. --- sysdeps/unix/sysv/linux/getsysstats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 1ef077f9af..a9069b7056 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/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_nocancel ("/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_nocancel_nostatus (fd);