From: cloudwalk Date: Thu, 4 Jun 2020 14:49:55 +0000 (+0000) Subject: Heap-allocate sessionid cvar's string to avoid stack corruption X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8bcef73b4693bfd28e2c44c4fd627cf4754c2867;p=xonotic%2Fdarkplaces.git Heap-allocate sessionid cvar's string to avoid stack corruption Previously it was trying to shove the address of a local variable, which is bad. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12633 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host.c b/host.c index 9a3d6ace..ae985c50 100644 --- a/host.c +++ b/host.c @@ -1112,17 +1112,21 @@ static qboolean locksession_run = false; static void Host_InitSession(void) { int i; + char *buf; Cvar_RegisterVariable(&sessionid); Cvar_RegisterVariable(&locksession); // load the session ID into the read-only cvar if ((i = COM_CheckParm("-sessionid")) && (i + 1 < com_argc)) { - char vabuf[1024]; if(com_argv[i+1][0] == '.') Cvar_SetQuick(&sessionid, com_argv[i+1]); else - Cvar_SetQuick(&sessionid, va(vabuf, sizeof(vabuf), ".%s", com_argv[i+1])); + { + buf = (char *)Z_Malloc(strlen(com_argv[i+1]+2)); + dpsnprintf(buf, sizeof(buf), ".%s", com_argv[i+1]); + Cvar_SetQuick(&sessionid, buf); + } } } void Host_LockSession(void)