Only check for port# after : in ConnectSocketByName
This commit is contained in:
parent
a6cd0b08f6
commit
45dcf63a62
1 changed files with 8 additions and 6 deletions
|
@ -464,12 +464,14 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
|
||||||
int port = portDefault;
|
int port = portDefault;
|
||||||
|
|
||||||
size_t colon = strDest.find_last_of(':');
|
size_t colon = strDest.find_last_of(':');
|
||||||
char *endp = NULL;
|
if (colon != strDest.npos) {
|
||||||
int n = strtol(pszDest + colon + 1, &endp, 10);
|
char *endp = NULL;
|
||||||
if (endp && *endp == 0 && n >= 0) {
|
int n = strtol(pszDest + colon + 1, &endp, 10);
|
||||||
strDest = strDest.substr(0, colon);
|
if (endp && *endp == 0 && n >= 0) {
|
||||||
if (n > 0 && n < 0x10000)
|
strDest = strDest.substr(0, colon);
|
||||||
port = n;
|
if (n > 0 && n < 0x10000)
|
||||||
|
port = n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (strDest[0] == '[' && strDest[strDest.size()-1] == ']')
|
if (strDest[0] == '[' && strDest[strDest.size()-1] == ']')
|
||||||
strDest = strDest.substr(1, strDest.size()-2);
|
strDest = strDest.substr(1, strDest.size()-2);
|
||||||
|
|
Loading…
Reference in a new issue