Save connect and playdemo argument before calling CL_Disconnect()

Save argument instead of using a pointer to cmd token memory that
might be overwritten when Cmd_TokenizeString() is called.

No known method for causing the issue without engine changes.
Cmd_TokenizeString() is called by FS_PureServerSetReferencedPaks()
in CL_Disconnect() but it's not an issue because the string is
blank.

Thanks @mickael9.
This commit is contained in:
Zack Middleton 2017-05-24 12:30:25 -05:00
parent 351e8f84d2
commit eecc8326a0

View file

@ -1069,7 +1069,8 @@ demo <demoname>
*/ */
void CL_PlayDemo_f( void ) { void CL_PlayDemo_f( void ) {
char name[MAX_OSPATH]; char name[MAX_OSPATH];
char *arg, *ext_test; char arg[MAX_OSPATH];
char *ext_test;
int protocol, i; int protocol, i;
char retry[MAX_OSPATH]; char retry[MAX_OSPATH];
@ -1083,7 +1084,7 @@ void CL_PlayDemo_f( void ) {
Cvar_Set( "sv_killserver", "2" ); Cvar_Set( "sv_killserver", "2" );
// open the demo file // open the demo file
arg = Cmd_Argv(1); Q_strncpyz( arg, Cmd_Argv(1), sizeof( arg ) );
CL_Disconnect( qtrue ); CL_Disconnect( qtrue );
@ -1690,7 +1691,7 @@ CL_Connect_f
================ ================
*/ */
void CL_Connect_f( void ) { void CL_Connect_f( void ) {
char *server; char server[MAX_OSPATH];
const char *serverString; const char *serverString;
int argc = Cmd_Argc(); int argc = Cmd_Argc();
netadrtype_t family = NA_UNSPEC; netadrtype_t family = NA_UNSPEC;
@ -1701,7 +1702,7 @@ void CL_Connect_f( void ) {
} }
if(argc == 2) if(argc == 2)
server = Cmd_Argv(1); Q_strncpyz( server, Cmd_Argv(1), sizeof( server ) );
else else
{ {
if(!strcmp(Cmd_Argv(1), "-4")) if(!strcmp(Cmd_Argv(1), "-4"))
@ -1711,7 +1712,7 @@ void CL_Connect_f( void ) {
else else
Com_Printf( "warning: only -4 or -6 as address type understood.\n"); Com_Printf( "warning: only -4 or -6 as address type understood.\n");
server = Cmd_Argv(2); Q_strncpyz( server, Cmd_Argv(2), sizeof( server ) );
} }
// save arguments for reconnect // save arguments for reconnect