From patchwork Thu Jan 7 01:06:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Haible X-Patchwork-Id: 41658 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com 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 3DD60388E82E; Thu, 7 Jan 2021 01:07:13 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.53]) by sourceware.org (Postfix) with ESMTPS id 3E4FA3846033 for ; Thu, 7 Jan 2021 01:07:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E4FA3846033 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=clisp.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=bruno@clisp.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1609981630; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From: Subject:Sender; bh=yFQtna7esoFOWH/fSy3xZ5SBLN81XuGcja70cDkS7sI=; b=fMWBccLdBunRCRKgRlbe85vzUOEpwutN0/GN9lc1Tg0hGslQ1Jm9y1ZDU934nfYRgg 6YqkG2JOcZVdWcEp7Q7P6btLo2YVWoNxAxHfQ3mlz/VeYWdArXtP4Y7tEaUYDV3yW+P0 tdQCHH2Arda2Skqq0fFj3kq5y6NNctd4j6KftQcJdvmcvMKxnhtQ0uC0knfhPVd1hJH4 angpYIFoG42t8EY8rmuJ0IEO4riZFGzr8xZtp9UyrHZsOmEw5cOuMXVDAvr4fDEyNm8C jcnW4pdIZs3OikVRanvapeszxNL8AJgk6gxwldH7TT4YjNZulvfCVmLCEt0SXRvB1wWV OF7g== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf3yZdW" X-RZG-CLASS-ID: mo00 Received: from omega.bruno.haible.de by smtp.strato.de (RZmta 47.12.1 DYNA|AUTH) with ESMTPSA id u0aa20x0717231t (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Thu, 7 Jan 2021 02:07:02 +0100 (CET) From: Bruno Haible To: libc-alpha@sourceware.org, Paul Eggert Subject: [PATCH 3/5] argp: Don't pass invalid arguments to isspace, isalnum, isalpha, isdigit. Date: Thu, 7 Jan 2021 02:06:18 +0100 Message-Id: <1609981580-17229-4-git-send-email-bruno@clisp.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609981580-17229-1-git-send-email-bruno@clisp.org> References: <1609981580-17229-1-git-send-email-bruno@clisp.org> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, 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: , Cc: Bruno Haible Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * lib/argp-help.c (SKIPWS): Cast character to 'unsigned char' before passing it to isspace(). (fill_in_uparams): Likewise for isalpha(), isalnum(), isdigit(). (canon_doc_option): Likewise for isspace(), isalnum(). Reviewed-by: Adhemerval Zanella --- argp/argp-help.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/argp/argp-help.c b/argp/argp-help.c index 5844d5b..d686a23 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -166,7 +166,7 @@ fill_in_uparams (const struct argp_state *state) { const char *var = getenv ("ARGP_HELP_FMT"); -#define SKIPWS(p) do { while (isspace (*p)) p++; } while (0); +#define SKIPWS(p) do { while (isspace ((unsigned char) *p)) p++; } while (0); if (var) /* Parse var. */ @@ -174,14 +174,14 @@ fill_in_uparams (const struct argp_state *state) { SKIPWS (var); - if (isalpha (*var)) + if (isalpha ((unsigned char) *var)) { size_t var_len; const struct uparam_name *un; int unspec = 0, val = 0; const char *arg = var; - while (isalnum (*arg) || *arg == '-' || *arg == '_') + while (isalnum ((unsigned char) *arg) || *arg == '-' || *arg == '_') arg++; var_len = arg - var; @@ -206,10 +206,10 @@ fill_in_uparams (const struct argp_state *state) else val = 1; } - else if (isdigit (*arg)) + else if (isdigit ((unsigned char) *arg)) { val = atoi (arg); - while (isdigit (*arg)) + while (isdigit ((unsigned char) *arg)) arg++; SKIPWS (arg); } @@ -713,12 +713,12 @@ canon_doc_option (const char **name) { int non_opt; /* Skip initial whitespace. */ - while (isspace (**name)) + while (isspace ((unsigned char) **name)) (*name)++; /* Decide whether this looks like an option (leading `-') or not. */ non_opt = (**name != '-'); /* Skip until part of name used for sorting. */ - while (**name && !isalnum (**name)) + while (**name && !isalnum ((unsigned char) **name)) (*name)++; return non_opt; }