]> 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>
Fri, 20 Dec 2013 11:34:44 +0000 (03:34 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 20 Dec 2013 11:34:44 +0000 (03:34 -0800)
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 c710bccc4dae340aa4dd573b2982962b936a4a53..bb4d86fd2d9050ca711201151c94a5fd5823a299 100644 (file)
@@ -1173,14 +1173,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;
@@ -1191,6 +1190,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 */