--------------------- PatchSet 1413 Date: 2005/05/22 15:49:36 Author: rmartinez Branch: squid3-ipv6 Tag: (none) Log: Fixing URL' parsing from file Members: src/cache_cf.cc:1.40.2.6->1.40.2.7 Index: squid3/src/cache_cf.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/cache_cf.cc,v retrieving revision 1.40.2.6 retrieving revision 1.40.2.7 diff -u -r1.40.2.6 -r1.40.2.7 --- squid3/src/cache_cf.cc 15 May 2005 14:48:29 -0000 1.40.2.6 +++ squid3/src/cache_cf.cc 22 May 2005 15:49:36 -0000 1.40.2.7 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.40.2.6 2005/05/15 14:48:29 rmartinez Exp $ + * $Id: cache_cf.cc,v 1.40.2.7 2005/05/22 15:49:36 rmartinez Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2595,26 +2595,15 @@ host = NULL; port = 0; + if (sscanf(token, "%d", &port) < 1 ) #ifdef INET6 -#error "FIXME when CURRENTLY_UNUSED becomes 1" - // Post: If you're not given the port, fail. - if (sscanf(token, "%d", &port) ) - if (sscanf(token, "%[^:]:%d", host, &port) < 2) - self_destruct(); -#endif - if ((t = strchr(token, ':'))) { - /* host:port */ - host = token; - *t = '\0'; - port = (unsigned short) xatoi(t + 1); + if (sscanf(url, "[%[^]]]:%d", host, &port) < 2) + /* the next "if sscanf" is intended nested when INET6 */ +#endif + if (sscanf(token, "%[^:]:%d", host, &port) < 2) + self_destruct(); + if (0 == port) self_destruct(); - if (0 == port) - self_destruct(); - } else if ((port = xatoi(token)) > 0) { - /* port */ - } else { - self_destruct(); - } s = static_cast(xcalloc(1, sizeof(*s))); PORT_FROM_SA(s->s) = htons(port); @@ -2688,19 +2677,14 @@ s->disable_pmtu_discovery = DISABLE_PMTU_OFF; - if ((t = strchr(token, ':'))) { - /* host:port */ - host = token; - *t = '\0'; - port = (unsigned short) atoi(t + 1); - - if (0 == port) - self_destruct(); - } else if ((port = atoi(token)) > 0) { - /* port */ - } else { - self_destruct(); - } + if (sscanf(token, "%d", &port) < 1 ) +#ifdef INET6 + if (sscanf(url, "[%[^]]]:%d", host, &port) < 2) + /* the next "if sscanf" is intended nested when INET6 */ +#endif + if (sscanf(token, "%[^:]:%d", host, &port) < 2) + self_destruct(); + if (0 == port) self_destruct(); PORT_FROM_SA(s->s) = htons(port);