nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit b5157dd9cb3fefd9261c430d7bce9ac483b1124d
parent 94812d17c8440ad4f6677961081963c19ef1d76e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 24 Feb 2023 17:15:42 +0100

tweaks: avoid calling isblank()/isalpha() on what could be a signed char

The isxxxxx() functions expect their parameter to be either EOF or
a value in the unsigned char range.  Passing a negative char value
could (in theory) result in unexpected behavior.

Diffstat:
Msrc/nano.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -2205,7 +2205,7 @@ int main(int argc, char **argv) alt_speller = alt_speller_cmdline; } /* Strip leading whitespace from the speller command, if any. */ - while (alt_speller && *alt_speller && isblank(*alt_speller)) + while (alt_speller && (*alt_speller == ' ' || *alt_speller == '\t')) memmove(alt_speller, alt_speller + 1, strlen(alt_speller)); #endif @@ -2443,7 +2443,7 @@ int main(int argc, char **argv) #ifndef NANO_TINY int n = 1; - while (isalpha(argv[optind][n])) { + while (isalpha((unsigned char)argv[optind][n])) { switch (argv[optind][n++]) { case 'c': SET(CASE_SENSITIVE); break; case 'C': UNSET(CASE_SENSITIVE); break;