Add locale independent implementations of isalpha, isalnum, isdigit,
and isxdigit.
All of these can be affected by locale, and although we weren't using
them directly (except for isxdigit) we instead had manual versions inline
everywhere.
While I am here add OPENSSL_fromxdigit and deduplicate a bunch of code
in hex decoders pulling out a hex value.
Change-Id: Ie75a4fba0f043208c50b0bb14174516462c89673
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56648
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/ssl/ssl_cipher.cc b/ssl/ssl_cipher.cc
index 7c4c034..391944a 100644
--- a/ssl/ssl_cipher.cc
+++ b/ssl/ssl_cipher.cc
@@ -1002,8 +1002,7 @@
rule = CIPHER_ADD;
l++;
continue;
- } else if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z') &&
- !(ch >= '0' && ch <= '9')) {
+ } else if (!OPENSSL_isalnum(ch)) {
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_OPERATOR_IN_GROUP);
return false;
} else {
@@ -1056,8 +1055,7 @@
ch = *l;
buf = l;
buf_len = 0;
- while ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') ||
- (ch >= 'a' && ch <= 'z') || ch == '-' || ch == '.' || ch == '_') {
+ while (OPENSSL_isalnum(ch) || ch == '-' || ch == '.' || ch == '_') {
ch = *(++l);
buf_len++;
}