diff options
author | Mattes D <github@xoft.cz> | 2015-01-25 16:25:15 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-01-27 14:53:32 +0100 |
commit | 6ec5e8caa77829d7ea3593b08f1f91244d027601 (patch) | |
tree | d5dafdb9e99e4648d0b257e34d23546a48e77bca | |
parent | Removed ListenThread and SocketThreads. (diff) | |
download | cuberite-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 |
-rw-r--r-- | src/Generating/BioGen.cpp | 3 | ||||
-rw-r--r-- | src/HTTPServer/HTTPMessage.cpp | 5 | ||||
-rw-r--r-- | src/HTTPServer/HTTPServer.cpp | 4 | ||||
-rw-r--r-- | src/RCONServer.cpp | 4 | ||||
-rw-r--r-- | src/Server.cpp | 4 |
5 files changed, 11 insertions, 9 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 2cc810d3b..378ece6a3 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -205,8 +205,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) int Count = 1; if (Split2.size() >= 2) { - Count = atol(Split2[1].c_str()); - if (Count <= 0) + if (!StringToInteger(Split2[1], Count)) { LOGWARNING("Cannot decode biome count: \"%s\"; using 1.", Split2[1].c_str()); Count = 1; 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; diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index 63bc97fe3..cd8409367 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -155,8 +155,8 @@ void cRCONServer::Initialize(cIniFile & a_IniFile) // Start listening on each specified port: for (auto port: Ports) { - UInt16 PortNum = static_cast<UInt16>(atol(port.c_str())); - if (PortNum == 0) + UInt16 PortNum; + if (!StringToInteger(port, PortNum)) { LOGINFO("Invalid RCON port value: \"%s\". Ignoring.", port.c_str()); continue; diff --git a/src/Server.cpp b/src/Server.cpp index 783b12947..3f61be378 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -393,8 +393,8 @@ bool cServer::Start(void) { for (auto port: m_Ports) { - UInt16 PortNum = static_cast<UInt16>(atoi(port.c_str())); - if (PortNum == 0) + UInt16 PortNum; + if (!StringToInteger(port, PortNum)) { LOGWARNING("Invalid port specified for server: \"%s\". Ignoring.", port.c_str()); continue; |