Fixed null pointer dereference in resolver (ticket #91).

The cycle->new_log.file may not be set before config parsing finished if
there are no error_log directive defined at global level.  Fix is to
copy it after config parsing.

Patch by Roman Arutyunyan.
This commit is contained in:
Maxim Dounin 2012-02-27 16:57:02 +00:00
parent 5c95f88503
commit 53d9677de4

View File

@ -189,11 +189,6 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
uc->sockaddr = u.addrs->sockaddr;
uc->socklen = u.addrs->socklen;
uc->server = u.addrs->name;
uc->log = cf->cycle->new_log;
uc->log.handler = ngx_resolver_log_error;
uc->log.data = uc;
uc->log.action = "resolving";
}
return r;
@ -876,6 +871,12 @@ ngx_resolver_send_query(ngx_resolver_t *r, ngx_resolver_node_t *rn)
}
if (uc->connection == NULL) {
uc->log = *r->log;
uc->log.handler = ngx_resolver_log_error;
uc->log.data = uc;
uc->log.action = "resolving";
if (ngx_udp_connect(uc) != NGX_OK) {
return NGX_ERROR;
}