diff options
author | Gregory Maxwell <gmaxwell@gmail.com> | 2012-05-12 18:55:36 -0700 |
---|---|---|
committer | Gregory Maxwell <gmaxwell@gmail.com> | 2012-05-12 18:55:36 -0700 |
commit | 6f7d45a3239519bb3a18893dea0875e80edc8c42 (patch) | |
tree | 5d1aea56c41131213f378681ebebc334fc5aff3d /src/netbase.cpp | |
parent | 22db3f2c773a1277310e760e86b6f3ea7e60f522 (diff) | |
parent | 5a3cb32e5942adbfb5af90808013c1dde3c03fcf (diff) | |
download | bitcoin-6f7d45a3239519bb3a18893dea0875e80edc8c42.tar.xz |
Merge pull request #1272 from sipa/ipv6fixes
A few IPv6 fixes
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 14 |
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); |