net_ws: allow to set custom IP address, use Q_strncpy instead of Q_strcpy

This commit is contained in:
Alibek Omarov 2018-11-02 01:06:23 +03:00
parent ef39f9c9cf
commit 18353d9ae6

View File

@ -1615,15 +1615,15 @@ void NET_GetLocalAddress( void )
// If we have changed the ip var from the command line, use that instead. // If we have changed the ip var from the command line, use that instead.
if( Q_strcmp( net_ipname->string, "localhost" )) if( Q_strcmp( net_ipname->string, "localhost" ))
{ {
Q_strcpy( buff, net_ipname->string ); Q_strncpy( buff, net_ipname->string, sizeof( buff ) );
} }
else else
{ {
pGetHostName( buff, 512 ); pGetHostName( buff, 512 );
}
// ensure that it doesn't overrun the buffer // ensure that it doesn't overrun the buffer
buff[511] = 0; buff[511] = 0;
}
if( NET_StringToAdr( buff, &net_local )) if( NET_StringToAdr( buff, &net_local ))
{ {
@ -1825,6 +1825,10 @@ void NET_Init( void )
if( Sys_GetParmFromCmdLine( "-port", cmd ) && Q_isdigit( cmd )) if( Sys_GetParmFromCmdLine( "-port", cmd ) && Q_isdigit( cmd ))
Cvar_FullSet( "hostport", cmd, FCVAR_READ_ONLY ); Cvar_FullSet( "hostport", cmd, FCVAR_READ_ONLY );
// specify custom ip
if( Sys_GetParmFromCmdLine( "-ip", cmd ))
Cvar_FullSet( "ip", cmd, FCVAR_READ_ONLY );
// adjust clockwindow // adjust clockwindow
if( Sys_GetParmFromCmdLine( "-clockwindow", cmd )) if( Sys_GetParmFromCmdLine( "-clockwindow", cmd ))
Cvar_SetValue( "clockwindow", Q_atof( cmd )); Cvar_SetValue( "clockwindow", Q_atof( cmd ));