Michael Rommel <rommel [at] layer-7.net>
Mark Brand <mabrand [at] mabrand.nl>
Vitaly Kruglikov <vitaly.kruglikov [at] palm.com>
+Kalle Olavi Niemitalo <kon [at] iki.fi>
----------------------------------------------------------------------
Copying and distribution of this file, with or without modification,
* return 1 on success or 0 on error
*
* note: certnamesize is required as X509 certs can contain embedded NULs in
- * the strings such as CN or subjectAltName
+ * the strings such as CN or subjectAltName.
+ *
+ * @level: is used for recursion. Use 0 when you call this function.
*/
int
_gnutls_hostname_compare (const char *certname,
- size_t certnamesize, const char *hostname)
+ size_t certnamesize, const char *hostname, int level)
{
+
+ if (level > 5)
+ return 0;
+
/* find the first different character */
for (; *certname && *hostname && c_toupper (*certname) == c_toupper (*hostname);
certname++, hostname++, certnamesize--)
while (1)
{
/* Use a recursive call to allow multiple wildcards */
- if (_gnutls_hostname_compare (certname, certnamesize, hostname))
+ if (_gnutls_hostname_compare (certname, certnamesize, hostname, level+1))
return 1;
/* wildcards are only allowed to match a single domain
size_t * bin_size);
int _gnutls_hostname_compare (const char *certname, size_t certnamesize,
- const char *hostname);
+ const char *hostname, int level);
#define MAX_CN 256
#define BUFFER_APPEND(b, x, s) { \
the terminating zero. */
dnsnamesize--;
- if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname))
+ if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname, 0))
return 1;
}
}
if (ret == GNUTLS_SAN_DNSNAME)
{
found_dnsname = 1;
- if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname))
+ if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname, 0))
{
return 1;
}
return 0;
}
- if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname))
+ if (_gnutls_hostname_compare (dnsname, dnsnamesize, hostname, 0))
{
return 1;
}