case insensitivity fix for domain name check

This commit is contained in:
Chris Conlon 2013-10-18 15:17:19 -06:00
parent 8295d8bb4a
commit f45d0709b3
2 changed files with 9 additions and 7 deletions

View File

@ -198,12 +198,14 @@ enum {
#endif
#endif
#if defined(HAVE_ECC) || defined(HAVE_OCSP)
#ifndef CTYPE_USER
#include <ctype.h>
#ifndef CTYPE_USER
#include <ctype.h>
#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

View File

@ -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;
}