Skip to content
Snippets Groups Projects
Commit 4a4be2ef authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge branch 'bug/#5' into 'main'

#5 Check port in URI parse

See merge request beyondaka/beyond-protocol!27
parents acbb9552 da7958f8
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,13 @@ void URI::_parse(uri_t puri) { ...@@ -120,7 +120,13 @@ void URI::_parse(uri_t puri) {
m_protostr = prototext; m_protostr = prototext;
std::string porttext = std::string(uri.portText.first, uri.portText.afterLast - uri.portText.first); std::string porttext = std::string(uri.portText.first, uri.portText.afterLast - uri.portText.first);
m_port = atoi(porttext.c_str()); try {
m_port = std::stoi(porttext);
if (m_port < 0 || m_port >= 65535) {
throw FTL_Error("Port out of range");
}
} catch (const std::invalid_argument &e) {}
m_userinfo = std::string(uri.userInfo.first, uri.userInfo.afterLast - uri.userInfo.first); m_userinfo = std::string(uri.userInfo.first, uri.userInfo.afterLast - uri.userInfo.first);
for (auto h = uri.pathHead; h != NULL; h = h->next) { for (auto h = uri.pathHead; h != NULL; h = h->next) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment