Repository: trafficserver
Updated Branches:
  refs/heads/master 14635098e -> f2facb7f6


TS-2905: Fix IP logging to print '0' instead of error text.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f2facb7f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f2facb7f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f2facb7f

Branch: refs/heads/master
Commit: f2facb7f603df27e8dc7613497887bc40896f9d9
Parents: 1463509
Author: Alan M. Carroll <[email protected]>
Authored: Tue Aug 19 22:08:16 2014 -0500
Committer: Alan M. Carroll <[email protected]>
Committed: Tue Aug 19 22:08:16 2014 -0500

----------------------------------------------------------------------
 CHANGES                    |  2 ++
 proxy/logging/LogAccess.cc | 33 +++++++++++++++++++++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2facb7f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a4f0f33..d8bc8b8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.1.0
 
+  *) [TS-2905] Change IP logging to print '0' instead of error text.
+
   *) [TS-2982] Interim cache compile errors.
 
   *) [TS-2584] Remove assert for negatively cached transformed objects.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2facb7f/proxy/logging/LogAccess.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index bf26472..1197de2 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -815,7 +815,9 @@ int
 LogAccess::marshal_ip(char* dest, sockaddr const* ip) {
   LogFieldIpStorage data;
   int len = sizeof(data._ip);
-  if (ats_is_ip4(ip)) {
+  if (NULL == ip) {
+    data._ip._family = AF_UNSPEC;
+  } else if (ats_is_ip4(ip)) {
     if (dest) {
       data._ip4._family = AF_INET;
       data._ip4._addr = ats_ip4_addr_cast(ip);
@@ -1211,9 +1213,18 @@ int
 LogAccess::unmarshal_ip_to_str(char **buf, char *dest, int len)
 {
   IpEndpoint ip;
-
-  unmarshal_ip(buf, &ip);
-  return ats_ip_ntop(&ip, dest, len) ? static_cast<int>(::strlen(dest)) : -1;
+  int zret = -1;
+
+  if (len > 0) {
+    unmarshal_ip(buf, &ip);
+    if (!ats_is_ip(&ip)) {
+      *dest = '0';
+      zret = 1;
+    } else if (ats_ip_ntop(&ip, dest, len)) {
+      zret = static_cast<int>(::strlen(dest));
+    }
+  }
+  return zret;
 }
 
 /*-------------------------------------------------------------------------
@@ -1227,9 +1238,19 @@ LogAccess::unmarshal_ip_to_str(char **buf, char *dest, 
int len)
 int
 LogAccess::unmarshal_ip_to_hex(char **buf, char *dest, int len)
 {
+  int zret = -1;
   IpEndpoint ip;
-  unmarshal_ip(buf, &ip);
-  return ats_ip_to_hex(&ip.sa, dest, len);
+
+  if (len > 0) {
+    unmarshal_ip(buf, &ip);
+    if (!ats_is_ip(&ip)) {
+      *dest = '0';
+      zret = 1;
+    } else {
+      zret = ats_ip_to_hex(&ip.sa, dest, len);
+    }
+  }
+  return zret;
 }
 
 /*-------------------------------------------------------------------------

Reply via email to