From: Bruno Haible Date: Tue, 8 Dec 2020 18:21:03 +0000 (+0100) Subject: argp: Don't pass invalid arguments to isspace() and isalnum(). X-Git-Tag: v1.0~3400 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=4b073774b23eb2c93c1d1601dd86899eb9852898;p=gnulib.git argp: Don't pass invalid arguments to isspace() and isalnum(). * lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int' before passing it to isspace() or isalnum(). --- diff --git a/ChangeLog b/ChangeLog index eaea8df7ca..3feedc1d33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-12-08 Bruno Haible + + argp: Don't pass invalid arguments to isspace() and isalnum(). + * lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int' + before passing it to isspace() or isalnum(). + 2020-12-08 Bruno Haible argp: Don't rely on undefined behaviour of _tolower(). diff --git a/lib/argp-help.c b/lib/argp-help.c index 03fc6c79eb..acab00146f 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -720,12 +720,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; }