MCPcopy Create free account
hub / github.com/apache/httpd / md_dns_is_name

Function md_dns_is_name

modules/md/md_util.c:811–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809/* DNS name checks ********************************************************************************/
810
811int md_dns_is_name(apr_pool_t *p, const char *hostname, int need_fqdn)
812{
813 char c, last = 0;
814 const char *cp = hostname;
815 int dots = 0;
816
817 /* Since we use the names in certificates, we need pure ASCII domain names
818 * and IDN need to be converted to unicode. */
819 while ((c = *cp++)) {
820 switch (c) {
821 case '.':
822 if (last == '.') {
823 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "dns name with ..: %s",
824 hostname);
825 return 0;
826 }
827 ++dots;
828 break;
829 case '-':
830 break;
831 default:
832 if (!apr_isalnum(c)) {
833 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "dns invalid char %c: %s",
834 c, hostname);
835 return 0;
836 }
837 break;
838 }
839 last = c;
840 }
841
842 if (last == '.') { /* DNS names may end with '.' */
843 --dots;
844 }
845 if (need_fqdn && dots <= 0) { /* do not accept just top level domains */
846 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "not a FQDN: %s", hostname);
847 return 0;
848 }
849 return 1; /* empty string not allowed */
850}
851
852int md_dns_is_wildcard(apr_pool_t *p, const char *domain)
853{

Callers 3

md_dns_is_wildcardFunction · 0.85
uri_checkFunction · 0.85
check_valuesFunction · 0.85

Calls 1

md_log_perrorFunction · 0.85

Tested by

no test coverage detected