]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
WCCPv2: fix assertion 'Cannot convert non-IPv4 to IPv4' on FreeBSD
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 25 Dec 2013 21:34:33 +0000 (14:34 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 25 Dec 2013 21:34:33 +0000 (14:34 -0700)
FreeBSD does not set the from-address on recv() if there was an error
reading the packet. This can result in Ip::Address assertion if the
error is not checked for before the IP address is mapped into Squid
internal format.

src/wccp2.cc

index b2c695a3a986610e4fd10c1c5c5038c37307ee6b..23b9e63da11fe66c46192c6b88b0b41319e7fb75 100644 (file)
@@ -1172,14 +1172,13 @@ wccp2HandleUdp(int sock, void *not_used)
 
     /* FIXME INET6 : drop conversion boundary */
     Ip::Address from_tmp;
+    from_tmp.setIPv4();
 
     len = comm_udp_recvfrom(sock,
                             &wccp2_i_see_you,
                             WCCP_RESPONSE_SIZE,
                             0,
                             from_tmp);
-    /* FIXME INET6 : drop conversion boundary */
-    from_tmp.getSockAddr(from);
 
     if (len < 0)
         return;
@@ -1190,6 +1189,9 @@ wccp2HandleUdp(int sock, void *not_used)
     if (ntohl(wccp2_i_see_you.type) != WCCP2_I_SEE_YOU)
         return;
 
+    /* FIXME INET6 : drop conversion boundary */
+    from_tmp.getSockAddr(from);
+
     debugs(80, 3, "Incoming WCCPv2 I_SEE_YOU length " << ntohs(wccp2_i_see_you.length) << ".");
 
     /* Record the total data length */