Loading...
Searching...
No Matches
XrdTlsHostcheck.icc File Reference
`#include <cstring>`
Include dependency graph for XrdTlsHostcheck.icc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

int | Curl_cert_hostcheck (const char *match_pattern, const char *hostname)
static int | Curl_raw_equal (const char *first, const char *second)
static int | Curl_raw_nequal (const char *first, const char *second, size_t max)
static char | Curl_raw_toupper (char in)
static int | hostmatch (const char *hostname, const char *pattern)

## Function Documentation

## Curl_cert_hostcheck()

int Curl_cert_hostcheck | ( | const char * | match_pattern,
|  | const char * | hostname )

Definition at line 205 of file XrdTlsHostcheck.icc.

{
if(!match_pattern || !*match_pattern ||
!hostname || !*hostname) /* sanity check */
return 0;
if(Curl_raw_equal(hostname, match_pattern)) /* trivial case */
return 1;
if(hostmatch(hostname,match_pattern) == CURL_HOST_MATCH)
return 1;
return 0;
}
CURL_HOST_MATCH
#define CURL_HOST_MATCH
Definition XrdTlsHostcheck.hh:26
Curl_raw_equal
static int Curl_raw_equal(const char *first, const char *second)
Definition XrdTlsHostcheck.icc:123
hostmatch
static int hostmatch(const char *hostname, const char *pattern)
Definition XrdTlsHostcheck.icc:163

References CURL_HOST_MATCH, Curl_raw_equal(), and hostmatch().

Referenced by matches_common_name(), and matches_subject_alternative_name().

Here is the call graph for this function:
Here is the caller graph for this function:

## Curl_raw_equal()

int Curl_raw_equal | ( | const char * | first,
|  | const char * | second )

static

Definition at line 123 of file XrdTlsHostcheck.icc.

{
while(*first && *second) {
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
/* get out of the loop as soon as they don't match */
break;
first++;
second++;
}
/* we do the comparison here (possibly again), just to make sure that if the
loop above is skipped because one of the strings reached zero, we must not
return this as a successful match */
return (Curl_raw_toupper(*first) == Curl_raw_toupper(*second));
}
Curl_raw_toupper
static char Curl_raw_toupper(char in)
Definition XrdTlsHostcheck.icc:54

References Curl_raw_toupper().

Referenced by Curl_cert_hostcheck(), and hostmatch().

Here is the call graph for this function:
Here is the caller graph for this function:

## Curl_raw_nequal()

int Curl_raw_nequal | ( | const char * | first,
|  | const char * | second,
|  | size_t | max )

static

Definition at line 138 of file XrdTlsHostcheck.icc.

{
while(*first && *second && max) {
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) {
break;
}
max--;
first++;
second++;
}
if(0 == max)
return 1; /* they are equal this far */
return Curl_raw_toupper(*first) == Curl_raw_toupper(*second);
}

References Curl_raw_toupper().

Referenced by hostmatch().

Here is the call graph for this function:
Here is the caller graph for this function:

## Curl_raw_toupper()

char Curl_raw_toupper | ( | char | in | ) |

static

Definition at line 54 of file XrdTlsHostcheck.icc.

{
switch (in) {
case 'a':
return 'A';
case 'b':
return 'B';
case 'c':
return 'C';
case 'd':
return 'D';
case 'e':
return 'E';
case 'f':
return 'F';
case 'g':
return 'G';
case 'h':
return 'H';
case 'i':
return 'I';
case 'j':
return 'J';
case 'k':
return 'K';
case 'l':
return 'L';
case 'm':
return 'M';
case 'n':
return 'N';
case 'o':
return 'O';
case 'p':
return 'P';
case 'q':
return 'Q';
case 'r':
return 'R';
case 's':
return 'S';
case 't':
return 'T';
case 'u':
return 'U';
case 'v':
return 'V';
case 'w':
return 'W';
case 'x':
return 'X';
case 'y':
return 'Y';
case 'z':
return 'Z';
}
return in;
}

Referenced by Curl_raw_equal(), and Curl_raw_nequal().

Here is the caller graph for this function:

## hostmatch()

int hostmatch | ( | const char * | hostname,
|  | const char * | pattern )

static

Definition at line 163 of file XrdTlsHostcheck.icc.

{
const char *pattern_label_end, *pattern_wildcard, *hostname_label_end;
int wildcard_enabled;
size_t prefixlen, suffixlen;
pattern_wildcard = strchr(pattern, '*');
if(pattern_wildcard == NULL)
return Curl_raw_equal(pattern, hostname) ?
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
/* We require at least 2 dots in pattern to avoid too wide wildcard
match. */
wildcard_enabled = 1;
pattern_label_end = strchr(pattern, '.');
if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL ||
pattern_wildcard > pattern_label_end ||
Curl_raw_nequal(pattern, "xn--", 4)) {
wildcard_enabled = 0;
}
if(!wildcard_enabled)
return Curl_raw_equal(pattern, hostname) ?
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
hostname_label_end = strchr(hostname, '.');
if(hostname_label_end == NULL ||
!Curl_raw_equal(pattern_label_end, hostname_label_end))
return CURL_HOST_NOMATCH;
/* The wildcard must match at least one character, so the left-most
label of the hostname is at least as large as the left-most label
of the pattern. */
if(hostname_label_end - hostname < pattern_label_end - pattern)
return CURL_HOST_NOMATCH;
prefixlen = pattern_wildcard - pattern;
suffixlen = pattern_label_end - (pattern_wildcard+1);
return Curl_raw_nequal(pattern, hostname, prefixlen) &&
Curl_raw_nequal(pattern_wildcard+1, hostname_label_end - suffixlen,
suffixlen) ?
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
}
CURL_HOST_NOMATCH
#define CURL_HOST_NOMATCH
Definition XrdTlsHostcheck.hh:25
Curl_raw_nequal
static int Curl_raw_nequal(const char *first, const char *second, size_t max)
Definition XrdTlsHostcheck.icc:138

References CURL_HOST_MATCH, CURL_HOST_NOMATCH, Curl_raw_equal(), and Curl_raw_nequal().

Referenced by Curl_cert_hostcheck().

Here is the call graph for this function:
Here is the caller graph for this function: