From: Eric Covener Date: Sat, 4 Dec 2010 04:14:03 +0000 (+0000) Subject: core: Fail startup when the argument to ServerName looks like a glob X-Git-Tag: 2.3.10~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5d3a4c3f4f59dbbf64020b03ae8bbbd91accbac;p=apache core: Fail startup when the argument to ServerName looks like a glob or a regular expression instead of a hostname (*?[]). PR 39863 Submitted By: Rahul Nair Reviewed By: covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1042098 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 4b98f15871..9c5dc53511 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.3.10 + *) core: Fail startup when the argument to ServerName looks like a glob + or a regular expression instead of a hostname (*?[]). PR 39863 + [Rahul Nair ] + *) mod_userdir: Add merging of enable, disable, and filename arguments to UserDir directive, leaving enable/disable of userlists unmerged. PR 44076 [Eric Covener] diff --git a/server/core.c b/server/core.c index ffeb98d9dc..7db086f26f 100644 --- a/server/core.c +++ b/server/core.c @@ -2354,6 +2354,15 @@ static const char *set_server_string_slot(cmd_parms *cmd, void *dummy, return NULL; } + +static const apr_status_t valid_hostname(const char* name) +{ + if (ap_strchr_c(name, '*') || ap_strchr_c(name, '?') || + ap_strchr_c(name, '[') || ap_strchr_c(name, ']')) { + return APR_EINVAL; + } + return APR_SUCCESS; +} /* * The ServerName directive takes one argument with format * [scheme://]fully-qualified-domain-name[:port], for instance @@ -2373,6 +2382,10 @@ static const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char return err; } + if (valid_hostname(arg) != APR_SUCCESS) + return apr_pstrcat(cmd->temp_pool, "Invalid ServerName \"", arg, + "\" use ServerAlias to set multiple server names.", NULL); + part = ap_strstr_c(arg, "://"); if (part) {