]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4497:
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 5 Mar 2012 13:06:29 +0000 (13:06 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 5 Mar 2012 13:06:29 +0000 (13:06 +0000)
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.

src/core/ngx_resolver.c

index 7291a1c5d53a3125ca5917cacb86dc530c47c5a3..7e77b191a9ff6831ed938ae4cda9737d747f8f0d 100644 (file)
@@ -152,11 +152,6 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_addr_t *addr)
         uc->sockaddr = addr->sockaddr;
         uc->socklen = addr->socklen;
         uc->server = addr->name;
-
-        uc->log = cf->cycle->new_log;
-        uc->log.handler = ngx_resolver_log_error;
-        uc->log.data = uc;
-        uc->log.action = "resolving";
     }
 
     return r;
@@ -830,6 +825,12 @@ ngx_resolver_send_query(ngx_resolver_t *r, ngx_resolver_node_t *rn)
     uc = r->udp_connection;
 
     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;
         }