Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Utils/WinHttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ namespace WinHttp {
size_t colon = hostPart.find(':');
if (colon != std::string::npos) {
out.host = std::wstring(hostPart.begin(), hostPart.begin() + colon);
out.port = static_cast<INTERNET_PORT>(std::stoi(hostPart.substr(colon + 1)));
auto portStr = hostPart.substr(colon + 1);
try {
size_t end = 0;
long port = std::stol(portStr, &end);
if (end != portStr.size() || port <= 0 || port > 65535) return out;
out.port = static_cast<INTERNET_PORT>(port);
} catch (...) {
return out;
}
} else {
out.host = std::wstring(hostPart.begin(), hostPart.end());
}
Expand Down
Loading