aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_core_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index cd4b8ed93..8a5e9d261 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -3094,17 +3094,24 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ch = value[1].data[0];
- if (cscf->server_name.data == NULL && value[1].len) {
- name = value[1];
+ if (cscf->server_name.data == NULL) {
+ if (value[1].len) {
+ name = value[1];
- if (ch == '.') {
- name.len--;
- name.data++;
- }
+ if (ch == '.') {
+ name.len--;
+ name.data++;
+ }
- cscf->server_name.len = name.len;
- cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
- if (cscf->server_name.data == NULL) {
+ cscf->server_name.len = name.len;
+ cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
+ if (cscf->server_name.data == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ } else {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "the first server name must not be empty");
return NGX_CONF_ERROR;
}
}
@@ -3113,8 +3120,7 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ch = value[i].data[0];
- if (value[i].len == 0
- || (ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
+ if ((ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
|| (ch == '.' && value[i].len < 2))
{
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,