summaryrefslogtreecommitdiffstats
path: root/src/HTTPServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/HTTPServer/HTTPMessage.cpp5
-rw-r--r--src/HTTPServer/HTTPServer.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp
index d59ca438e..c87b3cc8b 100644
--- a/src/HTTPServer/HTTPMessage.cpp
+++ b/src/HTTPServer/HTTPMessage.cpp
@@ -55,7 +55,10 @@ void cHTTPMessage::AddHeader(const AString & a_Key, const AString & a_Value)
}
else if (Key == "content-length")
{
- m_ContentLength = static_cast<size_t>(atol(m_Headers[Key].c_str()));
+ if (!StringToInteger(m_Headers[Key], m_ContentLength))
+ {
+ m_ContentLength = 0;
+ }
}
}
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index 3bcf0783a..71f974a97 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -225,8 +225,8 @@ bool cHTTPServer::Start(cCallbacks & a_Callbacks, const AStringVector & a_Ports)
// Open up requested ports:
for (auto port : a_Ports)
{
- UInt16 PortNum = static_cast<UInt16>(atoi(port.c_str()));
- if (PortNum == 0)
+ UInt16 PortNum;
+ if (!StringToInteger(port, PortNum))
{
LOGWARNING("WebServer: Invalid port value: \"%s\". Ignoring.", port.c_str());
continue;