Skip to content

Commit 45dcf63

Browse files
committed
Only check for port# after : in ConnectSocketByName
1 parent a6cd0b0 commit 45dcf63

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/netbase.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,14 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
464464
int port = portDefault;
465465

466466
size_t colon = strDest.find_last_of(':');
467-
char *endp = NULL;
468-
int n = strtol(pszDest + colon + 1, &endp, 10);
469-
if (endp && *endp == 0 && n >= 0) {
470-
strDest = strDest.substr(0, colon);
471-
if (n > 0 && n < 0x10000)
472-
port = n;
467+
if (colon != strDest.npos) {
468+
char *endp = NULL;
469+
int n = strtol(pszDest + colon + 1, &endp, 10);
470+
if (endp && *endp == 0 && n >= 0) {
471+
strDest = strDest.substr(0, colon);
472+
if (n > 0 && n < 0x10000)
473+
port = n;
474+
}
473475
}
474476
if (strDest[0] == '[' && strDest[strDest.size()-1] == ']')
475477
strDest = strDest.substr(1, strDest.size()-2);

0 commit comments

Comments
 (0)