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/objects/obj_dat.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crypto/objects/obj_dat.c') diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 4de346b5cb..3f65d37bc6 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -8,7 +8,7 @@ */ #include -#include +#include "internal/ctype.h" #include #include "internal/cryptlib.h" #include @@ -644,24 +644,24 @@ int OBJ_create_objects(BIO *in) if (i <= 0) return num; buf[i - 1] = '\0'; - if (!isalnum((unsigned char)buf[0])) + if (!ossl_isalnum(buf[0])) return num; o = s = buf; - while (isdigit((unsigned char)*s) || (*s == '.')) + while (ossl_isdigit(*s) || *s == '.') s++; if (*s != '\0') { *(s++) = '\0'; - while (isspace((unsigned char)*s)) + while (ossl_isspace(*s)) s++; if (*s == '\0') s = NULL; else { l = s; - while ((*l != '\0') && !isspace((unsigned char)*l)) + while (*l != '\0' && !ossl_isspace(*l)) l++; if (*l != '\0') { *(l++) = '\0'; - while (isspace((unsigned char)*l)) + while (ossl_isspace(*l)) l++; if (*l == '\0') l = NULL; -- cgit v1.2.3