actually use strtol as intended, checking for invalid inputs

This commit is contained in:
AJ Kelly
2011-03-27 19:19:31 -05:00
parent cab7c1f077
commit f4a9a3acc4
+10 -3
View File
@@ -112,9 +112,16 @@ void NetworkSyncManager::PostStartUp( const RString& ServerIP )
size_t cLoc = ServerIP.find( ':' );
if( ServerIP.find( ':' ) != RString::npos )
{
char* cEnd;
iPort = (unsigned short)strtol( ServerIP.substr( cLoc + 1 ).c_str(), &cEnd, 10 );
sAddress = ServerIP.substr( 0, cLoc );
char* cEnd;
errno = 0;
iPort = (unsigned short)strtol( ServerIP.substr( cLoc + 1 ).c_str(), &cEnd, 10 );
if( *cEnd != 0 || errno != 0 )
{
m_startupStatus = 2;
LOG->Warn( "Invalid port" );
return;
}
}
else
{
@@ -137,7 +144,7 @@ void NetworkSyncManager::PostStartUp( const RString& ServerIP )
useSMserver = true;
m_startupStatus = 1; //Connection attepmpt successful
m_startupStatus = 1; // Connection attepmpt successful
// If network play is desired and the connection works,
// halt until we know what server version we're dealing with