aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-05-03 10:25:58 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-09 16:45:57 +0200
commitd8642752992799b0695cf97ada03c56d0526830c (patch)
tree8533151117ed94ca9daad90056465e47cc436226 /src
parent0d4ea1cf8a349cf59795ac68645afe70e98c6b3a (diff)
Use new function parseint32 in SplitHostPort
Use the new function parseint32 in SplitHostPort instead of calling strtol directly.
Diffstat (limited to 'src')
-rw-r--r--src/netbase.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index ec275f738c..4f7e3f6b78 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -47,12 +47,10 @@ void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos);
if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) {
- char *endp = NULL;
- int n = strtol(in.c_str() + colon + 1, &endp, 10);
- if (endp && *endp == 0 && n >= 0) {
+ int32_t n;
+ if (ParseInt32(in.substr(colon + 1), &n) && n > 0 && n < 0x10000) {
in = in.substr(0, colon);
- if (n > 0 && n < 0x10000)
- portOut = n;
+ portOut = n;
}
}
if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']')