WCCPv2 patch to fix crashing during mask assignment.

From: Adrian Chadd <adrian@dont-contact.us>
Date: Thu, 7 Dec 2006 09:23:46 +0800

I've had a few people who have commented on the mask assignment code in squid-2.6
causing squid to crash.

The code in 2.6 almost DTRT - that loop is just being called once too many times.
I've shifted it around slightly to make it work again. No idea if/when it broke.

I'll commit this patch to fix the current behaviour to not crash squid unless
anyone has any objections.

Adrian

--- wccp2.c.20061206 2006-12-06 18:02:33.000000000 -0500
+++ wccp2.c 2006-12-06 18:27:42.000000000 -0500
@@ -1478,6 +1478,10 @@
                value = 0;
                for (valuecounter = 0; valuecounter < 64; valuecounter++) {
                    value_element = (struct wccp2_value_element_t *) &wccp_packet[offset];
+ /* Update the value according the the "correct" formula */
+ for (; (value & 0x1741) != value; value++) {
+ assert(value <= 0x1741);
+ }
 
                    if ((service_flags & WCCP2_SERVICE_SRC_IP_HASH) || (service_flags & WCCP2_SERVICE_SRC_IP_ALT_HASH)) {
                        value_element->source_ip_value = htonl(value);
@@ -1504,11 +1508,7 @@
                    }
                    value_element->cache_ip = cache_list_ptr->cache_ip;
                    offset += sizeof(struct wccp2_value_element_t);
-
- /* Update the value according the the "correct" formula */
- for (value++; (value & 0x1741) != value; value++) {
- assert(value <= 0x1741);
- }
+ value++;
 
                    /* Assign the next value to the next cache */
                    if ((cache_list_ptr->next) && (cache_list_ptr->next->next))

-- 
- Xenion - http://www.xenion.com.au/ - Hosting and Commercial Squid Support -
Received on Wed Dec 06 2006 - 18:22:41 MST

This archive was generated by hypermail pre-2.1.9 : Sat Dec 30 2006 - 12:00:04 MST