From: Stefan Fritsch Date: Sun, 22 Apr 2012 19:41:59 +0000 (+0000) Subject: Fix segfault in logging if r->useragent_addr or c->client_addr is unset X-Git-Tag: 2.5.0-alpha~7078 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07d44a6c4423e8697274abceee79a1016b0d2364;p=apache Fix segfault in logging if r->useragent_addr or c->client_addr is unset git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1328950 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index d5d70a947d..97de2c6989 100644 --- 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. diff --git a/server/log.c b/server/log.c index de560efce7..b33aa1fc1b 100644 --- a/server/log.c +++ b/server/log.c @@ -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 */