From 91f951ecd9f9d82f60335a0d2d73b1dd222282d0 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sat, 28 Feb 2015 14:33:10 +0100 Subject: [PATCH] Checking if ldap_server is defined before auth_ldap_servers. Getting segfault without this check. --- ngx_http_auth_ldap_module.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ngx_http_auth_ldap_module.c b/ngx_http_auth_ldap_module.c index 01e0f77..d9b7239 100644 --- a/ngx_http_auth_ldap_module.c +++ b/ngx_http_auth_ldap_module.c @@ -439,6 +439,12 @@ ngx_http_auth_ldap_servers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = &((ngx_str_t *) cf->args->elts)[i]; server = NULL; + if (mconf->servers == NULL) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "http_auth_ldap: Using \"auth_ldap_servers\" when no \"ldap_server\" has been previously defined" + " (make sure that \"auth_ldap_servers\" goes after \"ldap_server\"s in your configuration file)", value); + return NGX_CONF_ERROR; + } + for (j = 0; j < mconf->servers->nelts; j++) { s = &((ngx_http_auth_ldap_server_t *) mconf->servers->elts)[j]; if (s->alias.len == value->len && ngx_memcmp(s->alias.data, value->data, s->alias.len) == 0) {