aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-05-12 17:41:58 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-05-13 00:49:12 +0200
commit45dcf63a62402248bb5e54d5eb8985dd4d90db1b (patch)
treea3bf0a2cdcbe5259b4aaa4e3cef78737d4e1fca8 /src/netbase.cpp
parenta6cd0b08f6ef2af86fdff01154fe647e40b95424 (diff)
Only check for port# after : in ConnectSocketByName
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index ebf823e899..f09d981c49 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -464,12 +464,14 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
int port = portDefault;
size_t colon = strDest.find_last_of(':');
- char *endp = NULL;
- int n = strtol(pszDest + colon + 1, &endp, 10);
- if (endp && *endp == 0 && n >= 0) {
- strDest = strDest.substr(0, colon);
- if (n > 0 && n < 0x10000)
- port = n;
+ if (colon != strDest.npos) {
+ char *endp = NULL;
+ int n = strtol(pszDest + colon + 1, &endp, 10);
+ if (endp && *endp == 0 && n >= 0) {
+ strDest = strDest.substr(0, colon);
+ if (n > 0 && n < 0x10000)
+ port = n;
+ }
}
if (strDest[0] == '[' && strDest[strDest.size()-1] == ']')
strDest = strDest.substr(1, strDest.size()-2);