From: cloudwalk Date: Thu, 2 Jul 2020 17:19:38 +0000 (+0000) Subject: Fix trailing space in "cmd" not connected message. Make a vabuf MAX_INPUTLINE X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=379b116469f3803ff3ba334f192205c6a7ed231d;p=xonotic%2Fdarkplaces.git Fix trailing space in "cmd" not connected message. Make a vabuf MAX_INPUTLINE git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12777 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_cmd.c b/cl_cmd.c index 2d00c7a5..b6e6e8c0 100644 --- a/cl_cmd.c +++ b/cl_cmd.c @@ -170,7 +170,8 @@ void CL_ForwardToServer (const char *s) void CL_ForwardToServer_f (cmd_state_t *cmd) { const char *s; - char vabuf[1024]; + char vabuf[MAX_INPUTLINE]; + size_t i; if (!strcasecmp(Cmd_Argv(cmd, 0), "cmd")) { // we want to strip off "cmd", so just send the args @@ -179,7 +180,10 @@ void CL_ForwardToServer_f (cmd_state_t *cmd) else { // we need to keep the command name, so send Cmd_Argv(cmd, 0), a space and then Cmd_Args(cmd) - s = va(vabuf, sizeof(vabuf), "%s %s", Cmd_Argv(cmd, 0), Cmd_Argc(cmd) > 1 ? Cmd_Args(cmd) : ""); + i = dpsnprintf(vabuf, sizeof(vabuf), "%s", Cmd_Argv(cmd, 0)); + if(Cmd_Argc(cmd) > 1) + dpsnprintf(&vabuf[i], sizeof(vabuf - i), " %s", Cmd_Args(cmd)); + s = vabuf; } // don't send an empty forward message if the user tries "cmd" by itself if (!s || !*s)