Skip to content

Commit fac9fe5

Browse files
author
MarcoFalke
committed
Fix unintended unsigned integer overflow in strencodings
1 parent 8ac7997 commit fac9fe5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/util/strencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void SplitHostPort(std::string in, uint16_t& portOut, std::string& hostOut)
113113
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
114114
bool fHaveColon = colon != in.npos;
115115
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
116-
bool fMultiColon = fHaveColon && (in.find_last_of(':', colon - 1) != in.npos);
116+
bool fMultiColon{fHaveColon && colon != 0 && (in.find_last_of(':', colon - 1) != in.npos)};
117117
if (fHaveColon && (colon == 0 || fBracketed || !fMultiColon)) {
118118
uint16_t n;
119119
if (ParseUInt16(in.substr(colon + 1), &n)) {

0 commit comments

Comments
 (0)