------------------------------------------------------------ revno: 11826 revision-id: squid3@treenet.co.nz-20130713124108-55ve768vfrd4sbkc parent: squid3@treenet.co.nz-20130713123806-pteg9ouzldmxpu8h committer: Amos Jeffries branch nick: 3.2 timestamp: Sat 2013-07-13 06:41:08 -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-20130713124108-55ve768vfrd4sbkc # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: a8072203e76e80d4ffb5b6a4cfe7b95f0dd30a4d # timestamp: 2013-07-13 12:41:42 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20130713123806-\ # pteg9ouzldmxpu8h # # Begin patch === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2013-03-29 06:13:27 +0000 +++ src/client_side_request.cc 2013-07-13 12:41:08 +0000 @@ -641,8 +641,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"));