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( ':' );
|
size_t cLoc = ServerIP.find( ':' );
|
||||||
if( ServerIP.find( ':' ) != RString::npos )
|
if( ServerIP.find( ':' ) != RString::npos )
|
||||||
{
|
{
|
||||||
char* cEnd;
|
|
||||||
iPort = (unsigned short)strtol( ServerIP.substr( cLoc + 1 ).c_str(), &cEnd, 10 );
|
|
||||||
sAddress = ServerIP.substr( 0, cLoc );
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user