------------------------------------------------------------ revno: 12591 revision-id: squid3@treenet.co.nz-20130713124022-jso5s9d2rx22k5oa parent: squid3@treenet.co.nz-20130713123735-wh3op52v6qc9phf2 committer: Amos Jeffries branch nick: 3.3 timestamp: Sat 2013-07-13 06:40:22 -0600 message: Better handling of strange port values in Host: We can do better than just producing errors about invalid port details and treating it as port-0. We can instead undo the port separation and pass it through as part of the host name to be verified with the default port number properly assumed. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20130713124022-jso5s9d2rx22k5oa # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: f176442a43b39db4ebcc22e10d48d6ca2c997dd9 # timestamp: 2013-07-13 12:41:33 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20130713123735-\ # wh3op52v6qc9phf2 # # Begin patch === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2013-03-29 05:55:45 +0000 +++ src/client_side_request.cc 2013-07-13 12:40:22 +0000 @@ -659,8 +659,16 @@ uint16_t port = 0; if (portStr) { *portStr = '\0'; // strip the ':' - if (*(++portStr) != '\0') - port = xatoi(portStr); + if (*(++portStr) != '\0') { + char *end = NULL; + int64_t ret = strtoll(portStr, &end, 10); + if (end == portStr || *end != '\0' || ret < 1 || ret > 0xFFFF) { + // invalid port details. Replace the ':' + *(--portStr) = ':'; + portStr = NULL; + } else + port = (ret & 0xFFFF); + } } debugs(85, 3, HERE << "validate host=" << host << ", port=" << port << ", portStr=" << (portStr?portStr:"NULL"));