summaryrefslogtreecommitdiffstats
path: root/src/HTTPServer
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-25 16:25:15 +0100
committerMattes D <github@xoft.cz>2015-01-27 14:53:32 +0100
commit6ec5e8caa77829d7ea3593b08f1f91244d027601 (patch)
treed5dafdb9e99e4648d0b257e34d23546a48e77bca /src/HTTPServer
parentRemoved ListenThread and SocketThreads. (diff)
downloadcuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar.gz
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar.bz2
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar.lz
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar.xz
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.tar.zst
cuberite-6ec5e8caa77829d7ea3593b08f1f91244d027601.zip
Diffstat (limited to 'src/HTTPServer')
-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;