X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fctype.c;h=e7bc25b9766130a5180635a6060356fb0913bdca;hp=89ed5bf486b95b5725551076b7b845b0184bc080;hb=e7b81fe67a5dd95af72e090fff6fd0749ee88553;hpb=a1df06b36347a31c17d09e6ca3e1464bdf7eb4d5 diff --git a/crypto/ctype.c b/crypto/ctype.c index 89ed5bf486..e7bc25b976 100644 --- a/crypto/ctype.c +++ b/crypto/ctype.c @@ -1,13 +1,14 @@ /* * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include +#include #include "internal/ctype.h" #include "openssl/ebcdic.h" @@ -225,7 +226,7 @@ static const unsigned short ctype_char_map[128] = { #ifdef CHARSET_EBCDIC int ossl_toascii(int c) { - if (c < -128 || c > 256) + if (c < -128 || c > 256 || c == EOF) return c; /* * Adjust negatively signed characters. @@ -240,7 +241,7 @@ int ossl_toascii(int c) int ossl_fromascii(int c) { - if (c < -128 || c > 256) + if (c < -128 || c > 256 || c == EOF) return c; if (c < 0) c += 256; @@ -251,9 +252,9 @@ int ossl_fromascii(int c) int ossl_ctype_check(int c, unsigned int mask) { const int max = sizeof(ctype_char_map) / sizeof(*ctype_char_map); + const int a = ossl_toascii(c); - c = ossl_toascii(c); - return c >= 0 && c < max && (ctype_char_map[c] & mask) != 0; + return a >= 0 && a < max && (ctype_char_map[a] & mask) != 0; } #if defined(CHARSET_EBCDIC) && !defined(CHARSET_EBCDIC_TEST) @@ -271,3 +272,9 @@ int ossl_toupper(int c) { return ossl_islower(c) ? c ^ case_change : c; } + +int ascii_isdigit(const char inchar) { + if (inchar > 0x2F && inchar < 0x3A) + return 1; + return 0; +}