From: Michael Baentsch <57787676+baentsch@users.noreply.github.com> Date: Mon, 5 Jun 2023 11:09:29 +0000 (+0200) Subject: Cast the argument to unsigned char when calling isdigit() X-Git-Tag: openssl-3.1.2~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ffe629a7f57424a460a05b7064a374835b1c279;p=thirdparty%2Fopenssl.git Cast the argument to unsigned char when calling isdigit() Fixes #21123 Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21127) (cherry picked from commit 8229874476cc2955e6947cf6d3fee09e13b8c160) --- diff --git a/apps/s_client.c b/apps/s_client.c index f056adb68e9..d82b02d1929 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2272,7 +2272,7 @@ int s_client_main(int argc, char **argv) do { mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); } - while (mbuf_len > 3 && (!isdigit(mbuf[0]) || !isdigit(mbuf[1]) || !isdigit(mbuf[2]) || mbuf[3] != ' ')); + while (mbuf_len > 3 && (!isdigit((unsigned char)mbuf[0]) || !isdigit((unsigned char)mbuf[1]) || !isdigit((unsigned char)mbuf[2]) || mbuf[3] != ' ')); (void)BIO_flush(fbio); BIO_pop(fbio); BIO_free(fbio); diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c index bc0e924e46a..aa266c59792 100644 --- a/crypto/LPdir_unix.c +++ b/crypto/LPdir_unix.c @@ -137,7 +137,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) if ((*ctx)->expect_file_generations) { char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name); - while(p > (*ctx)->entry_name && isdigit(p[-1])) + while (p > (*ctx)->entry_name && isdigit((unsigned char)p[-1])) p--; if (p > (*ctx)->entry_name && p[-1] == ';') p[-1] = '\0'; diff --git a/engines/e_loader_attic.c b/engines/e_loader_attic.c index 87056c4de17..6a1df9b23cb 100644 --- a/engines/e_loader_attic.c +++ b/engines/e_loader_attic.c @@ -1486,9 +1486,9 @@ static int file_name_check(OSSL_STORE_LOADER_CTX *ctx, const char *name) * Last, check that the rest of the extension is a decimal number, at * least one digit long. */ - if (!isdigit(*p)) + if (!isdigit((unsigned char)*p)) return 0; - while (isdigit(*p)) + while (isdigit((unsigned char)*p)) p++; #ifdef __VMS diff --git a/providers/implementations/storemgmt/file_store.c b/providers/implementations/storemgmt/file_store.c index 6d6312659be..b5bb1dc92a0 100644 --- a/providers/implementations/storemgmt/file_store.c +++ b/providers/implementations/storemgmt/file_store.c @@ -612,9 +612,9 @@ static int file_name_check(struct file_ctx_st *ctx, const char *name) * Last, check that the rest of the extension is a decimal number, at * least one digit long. */ - if (!isdigit(*p)) + if (!isdigit((unsigned char)*p)) return 0; - while (isdigit(*p)) + while (isdigit((unsigned char)*p)) p++; #ifdef __VMS @@ -623,7 +623,7 @@ static int file_name_check(struct file_ctx_st *ctx, const char *name) */ if (*p == ';') for (p++; *p != '\0'; p++) - if (!ossl_isdigit(*p)) + if (!ossl_isdigit((unsigned char)*p)) break; #endif diff --git a/test/testutil/provider.c b/test/testutil/provider.c index 5d5991f5025..3f94d7506e8 100644 --- a/test/testutil/provider.c +++ b/test/testutil/provider.c @@ -201,7 +201,7 @@ int fips_provider_version_match(OSSL_LIB_CTX *libctx, const char *versions) } else if (*p == '>') { mode = MODE_GT; p++; - } else if (isdigit(*p)) { + } else if (isdigit((unsigned char)*p)) { mode = MODE_EQ; } else { TEST_info("Error matching FIPS version: mode %s\n", p);