actually use strtol as intended, checking for invalid inputs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user