[nginx] svn commit: r4497 - trunk/src/core

mdounin at mdounin.ru mdounin at mdounin.ru
Mon Feb 27 16:57:03 UTC 2012


Author: mdounin
Date: 2012-02-27 16:57:02 +0000 (Mon, 27 Feb 2012)
New Revision: 4497

Log:
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.


Modified:
   trunk/src/core/ngx_resolver.c

Modified: trunk/src/core/ngx_resolver.c
===================================================================
--- trunk/src/core/ngx_resolver.c	2012-02-27 16:54:10 UTC (rev 4496)
+++ trunk/src/core/ngx_resolver.c	2012-02-27 16:57:02 UTC (rev 4497)
@@ -189,11 +189,6 @@
         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 @@
     }
 
     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;
         }



More information about the nginx-devel mailing list