From: Otto Moerbeek Date: Tue, 25 Aug 2020 07:48:15 +0000 (+0200) Subject: Try to be abit more smart in recognizing IP:port combos for both X-Git-Tag: auth-4.4.0-alpha2~49^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f04c25fd09353af041c27bd6388f4646cdece650;p=thirdparty%2Fpdns.git Try to be abit more smart in recognizing IP:port combos for both IPV4 and IPv6. Should fix #7743 --- diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 87ec45732c..487781b289 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -261,20 +261,24 @@ static void makeIPToNamesZone(std::shared_ptr newMap, cons ComboAddress parseIPAndPort(const std::string& input, uint16_t port) { - if(input.find(':') == string::npos || input.empty()) // common case + if (input.find(':') == string::npos || input.empty()) { // common case return ComboAddress(input, port); + } pair both; - try { // case 2 - both=splitField(input,':'); - uint16_t newport=static_cast(pdns_stou(both.second)); + string::size_type cpos = input.rfind(':'); + both.first = input.substr(0, cpos); + both.second = input.substr(cpos + 1); + + uint16_t newport = static_cast(pdns_stou(both.second)); return ComboAddress(both.first, newport); - } - catch(...){} + } + catch(...) { + } - if(input[0]=='[') { // case 4 - both=splitField(input.substr(1),']'); + if (input[0] == '[') { // case 4 + both = splitField(input.substr(1), ']'); return ComboAddress(both.first, both.second.empty() ? port : static_cast(pdns_stou(both.second.substr(1)))); }