Cast the argument to unsigned char when calling isdigit()

Fixes #21123

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21127)
This commit is contained in:
Michael Baentsch 2023-06-05 13:09:29 +02:00 committed by Tomas Mraz
parent 18f82df5b1
commit 8229874476
5 changed files with 8 additions and 8 deletions

View File

@ -2466,7 +2466,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);

View File

@ -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';

View File

@ -1470,9 +1470,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

View File

@ -608,9 +608,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
@ -619,7 +619,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

View File

@ -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);