trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1199112 - in /trafficserver/traffic/trunk/proxy/logging: LogAccess.cc LogField.h
Date Tue, 08 Nov 2011 05:23:16 GMT
Author: amc
Date: Tue Nov  8 05:23:16 2011
New Revision: 1199112

URL: http://svn.apache.org/viewvc?rev=1199112&view=rev
Log:
TS-989 probable fix for stack corruption.

Modified:
    trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
    trafficserver/traffic/trunk/proxy/logging/LogField.h

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccess.cc?rev=1199112&r1=1199111&r2=1199112&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccess.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccess.cc Tue Nov  8 05:23:16 2011
@@ -793,24 +793,22 @@ LogAccess::marshal_mem(char *dest, const
 
 int
 LogAccess::marshal_ip(char* dest, sockaddr const* ip) {
-  LogFieldIp data;
-  int len = sizeof(data);
+  LogFieldIpStorage data;
+  int len = sizeof(data._ip);
   if (ink_inet_is_ip4(ip)) {
     if (dest) {
-      LogFieldIp4* ip4 = static_cast<LogFieldIp4*>(&data);
-      ip4->_family = AF_INET;
-      ip4->_addr = ink_inet_ip4_addr_cast(ip);
+      data._ip4._family = AF_INET;
+      data._ip4._addr = ink_inet_ip4_addr_cast(ip);
     }
-    len = sizeof(LogFieldIp4);
+    len = sizeof(data._ip4);
   } else if (ink_inet_is_ip6(ip)) {
     if (dest) {
-      LogFieldIp6* ip6 = static_cast<LogFieldIp6*>(&data);
-      ip6->_family = AF_INET6;
-      ip6->_addr = ink_inet_ip6_addr_cast(ip);
+      data._ip6._family = AF_INET6;
+      data._ip6._addr = ink_inet_ip6_addr_cast(ip);
     }
-    len = sizeof(LogFieldIp6);
+    len = sizeof(data._ip6);
   } else {
-    data._family = AF_UNSPEC;
+    data._ip._family = AF_UNSPEC;
   }
 
   if (dest) memcpy(dest, &data, len);

Modified: trafficserver/traffic/trunk/proxy/logging/LogField.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogField.h?rev=1199112&r1=1199111&r2=1199112&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogField.h (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogField.h Tue Nov  8 05:23:16 2011
@@ -222,5 +222,11 @@ struct LogFieldIp4 : public LogFieldIp {
 struct LogFieldIp6 : public LogFieldIp {
   in6_addr _addr; ///< IPv6 address.
 };
+/// Something big enough to hold any of the IP field types.
+union LogFieldIpStorage {
+  LogFieldIp _ip;
+  LogFieldIp4 _ip4;
+  LogFieldIp6 _ip6;
+};
 
 #endif



Mime
View raw message