From d516b0dd41e3394757888c4976bd706a8c476f12 Mon Sep 17 00:00:00 2001 From: Rinat Ibragimov Date: Sat, 4 Feb 2017 17:54:42 +0300 Subject: [PATCH] Require alcf->server array to be non-empty before using it --- ngx_http_auth_ldap_module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ngx_http_auth_ldap_module.c b/ngx_http_auth_ldap_module.c index e6a1ab3..58e6087 100644 --- a/ngx_http_auth_ldap_module.c +++ b/ngx_http_auth_ldap_module.c @@ -1756,6 +1756,13 @@ ngx_http_auth_ldap_handler(ngx_http_request_t *r) return NGX_DECLINED; } + if (alcf->servers == NULL || alcf->servers->nelts == 0) { + /* No LDAP servers for the location. */ + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "http_auth_ldap: \"auth_ldap\" requires " + "one or more \"auth_ldap_servers\" in the same location"); + return ngx_http_auth_ldap_set_realm(r, &alcf->realm); + } + ctx = ngx_http_get_module_ctx(r, ngx_http_auth_ldap_module); if (ctx == NULL) { rc = ngx_http_auth_basic_user(r);