From a1df06b36347a31c17d09e6ca3e1464bdf7eb4d5 Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 21 Aug 2017 07:19:17 +1000 Subject: This has been added to avoid the situation where some host ctype.h functions return true for characters > 127. I.e. they are allowing extended ASCII characters through which then cause problems. E.g. marking superscript '2' as a number then causes the common (ch - '0') conversion to number to fail miserably. Likewise letters with diacritical marks can also cause problems. If a non-ASCII character set is being used (currently only EBCDIC), it is adjusted for. The implementation uses a single table with a bit for each of the defined classes. These functions accept an int argument and fail for values out of range or for characters outside of the ASCII set. They will work for both signed and unsigned character inputs. Reviewed-by: Andy Polyakov (Merged from https://github.com/openssl/openssl/pull/4102) --- crypto/bio/b_addr.c | 3 +-- crypto/bio/b_print.c | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'crypto/bio') diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index d0b2428450..6d854927fe 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,7 +17,6 @@ #include #include #include -#include CRYPTO_RWLOCK *bio_lookup_lock; static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT; diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index ebb6845dbd..eeee52e8c1 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,7 +9,7 @@ #include #include -#include +#include "internal/ctype.h" #include "internal/numbers.h" #include "internal/cryptlib.h" #include @@ -143,7 +143,7 @@ _dopr(char **sbuffer, } break; case DP_S_MIN: - if (isdigit((unsigned char)ch)) { + if (ossl_isdigit(ch)) { min = 10 * min + char_to_int(ch); ch = *format++; } else if (ch == '*') { @@ -161,7 +161,7 @@ _dopr(char **sbuffer, state = DP_S_MOD; break; case DP_S_MAX: - if (isdigit((unsigned char)ch)) { + if (ossl_isdigit(ch)) { if (max < 0) max = 0; max = 10 * max + char_to_int(ch); -- cgit v1.2.3