--------------------- PatchSet 3011 Date: 2001/09/12 14:43:37 Author: adri Branch: peertwiddle Tag: (none) Log: Some code to split the host:port string into a host and port, with some verification. Members: src/neighbors.c:1.12.14.3->1.12.14.4 Index: squid/src/neighbors.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/neighbors.c,v retrieving revision 1.12.14.3 retrieving revision 1.12.14.4 diff -u -r1.12.14.3 -r1.12.14.4 --- squid/src/neighbors.c 12 Sep 2001 14:35:57 -0000 1.12.14.3 +++ squid/src/neighbors.c 12 Sep 2001 14:43:37 -0000 1.12.14.4 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.c,v 1.12.14.3 2001/09/12 14:35:57 adri Exp $ + * $Id: neighbors.c,v 1.12.14.4 2001/09/12 14:43:37 adri Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -1403,18 +1403,26 @@ { http_version_t version; char unknown_req[] = "Unknown or invalid administrative peer request\n"; - LOCAL_ARRAY(char, host, MAX_URL); + LOCAL_ARRAY(char, thost, MAX_URL); LOCAL_ARRAY(char, adminreq, MAX_URL); + LOCAL_ARRAY(char, peer_host, MAX_URL); + unsigned int peer_port; int t; const char *url = strBuf(request->urlpath); + peer *peer; - t = sscanf(url, "/squid-internal-peer/%[^/]/%s", host, adminreq); + t = sscanf(url, "/squid-internal-peer/%[^/]/%s", thost, adminreq); if (t < 2) goto error; - debug(1, 1) ("peer: %s, adminreq: %s\n", host, adminreq); + debug(1, 1) ("peer: %s, adminreq: %s\n", thost, adminreq); - /* Attempt to parse the peer */ + /* Attempt to split a host:port string into the two seperate bits */ + t = sscanf(thost, "%[^:]:%d", peer_host, &peer_port); + if (t < 2) + goto error; + + debug(1, 1) ("host: %s, port %d\n", peer_host, peer_port); /* Valid peer? */ /* No, set invalid response, quit */