]> granicus.if.org Git - apache/commitdiff
Fix segfault in logging if r->useragent_addr or c->client_addr is unset
authorStefan Fritsch <sf@apache.org>
Sun, 22 Apr 2012 19:41:59 +0000 (19:41 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 22 Apr 2012 19:41:59 +0000 (19:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1328950 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/log.c

diff --git a/CHANGES b/CHANGES
index d5d70a947d833f05ca37d8893803e88334271296..97de2c6989534da9549ba388948124cf7d80a4e2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) core: Fix segfault in logging if r->useragent_addr or c->client_addr is
+     unset. [Stefan Fritsch]
+
   *) cross-compile: allow to provide CC_FOR_BUILD so that gen_test_char will
      be compiled by the build compiler instead of the host compiler.
      Also set CC_FOR_BUILD to 'cc' when cross-compilation is detected.
index de560efce704854bd7c61556fa617b65fc56bee4..b33aa1fc1b98b296763ae366998fe5ce1b3e6ea5 100644 (file)
@@ -563,10 +563,10 @@ static int log_remote_address(const ap_errorlog_info *info, const char *arg,
 {
     if (info->r && !(arg && *arg == 'c'))
         return apr_snprintf(buf, buflen, "%s:%d", info->r->useragent_ip,
-                            info->r->useragent_addr->port);
+                            info->r->useragent_addr ? info->r->useragent_addr->port : 0);
     else if (info->c)
         return apr_snprintf(buf, buflen, "%s:%d", info->c->client_ip,
-                            info->c->client_addr->port);
+                            info->c->client_addr ? info->c->client_addr->port : 0);
     else
         return 0;
 }
@@ -968,12 +968,14 @@ static int do_errorlog_default(const ap_errorlog_info *info, char *buf,
     if (info->r) {
         len += apr_snprintf(buf + len, buflen - len,
                             info->r->connection->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
-                            info->r->useragent_ip, info->r->useragent_addr->port);
+                            info->r->useragent_ip,
+                            info->r->useragent_addr ? info->r->useragent_addr->port : 0);
     }
     else if (info->c) {
         len += apr_snprintf(buf + len, buflen - len,
                             info->c->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
-                            info->c->client_ip, info->c->client_addr->port);
+                            info->c->client_ip,
+                            info->c->client_addr ? info->c->client_addr->port : 0);
     }
 
     /* the actual error message */