From f45d0709b3a0616b67ce0e8c3d2eaf5708b13230 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Fri, 18 Oct 2013 15:17:19 -0600 Subject: [PATCH] case insensitivity fix for domain name check --- cyassl/ctaocrypt/types.h | 8 +++++--- src/internal.c | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cyassl/ctaocrypt/types.h b/cyassl/ctaocrypt/types.h index 6e310ac86..8c44bb89f 100644 --- a/cyassl/ctaocrypt/types.h +++ b/cyassl/ctaocrypt/types.h @@ -198,12 +198,14 @@ enum { #endif #endif -#if defined(HAVE_ECC) || defined(HAVE_OCSP) - #ifndef CTYPE_USER - #include +#ifndef CTYPE_USER + #include + #if defined(HAVE_ECC) || defined(HAVE_OCSP) #define XTOUPPER(c) toupper((c)) #define XISALPHA(c) isalpha((c)) #endif + /* needed by CyaSSL_check_domain_name() */ + #define XTOLOWER(c) tolower((c)) #endif diff --git a/src/internal.c b/src/internal.c index 0f55ca980..7d5cb9d8e 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2909,15 +2909,15 @@ static int MatchDomainName(const char* pattern, int len, const char* str) if (pattern == NULL || str == NULL || len <= 0) return 0; - while (len > 0 && (p = (char)(*pattern++))) { + while (len > 0 && (p = (char)XTOLOWER(*pattern++))) { if (p == '*') { - while (--len > 0 && (p = (char)(*pattern++)) == '*') + while (--len > 0 && (p = (char)XTOLOWER(*pattern++)) == '*') ; if (len == 0) p = '\0'; - while ( (s = (char)(*str)) != '\0') { + while ( (s = (char)XTOLOWER(*str)) != '\0') { if (s == p) break; if (s == '.') @@ -2926,7 +2926,7 @@ static int MatchDomainName(const char* pattern, int len, const char* str) } } else { - if (p != (char)(*str)) + if (p != (char)XTOLOWER(*str)) return 0; }