]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix trailing space in "cmd" not connected message. Make a vabuf MAX_INPUTLINE
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 2 Jul 2020 17:19:38 +0000 (17:19 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 2 Jul 2020 17:19:38 +0000 (17:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12777 d7cf8633-e32d-0410-b094-e92efae38249

cl_cmd.c

index 2d00c7a5878f59bb0a1d5e801b9ecb7fc1be1548..b6e6e8c05b3b67c14b5133b5e74c153e05958350 100644 (file)
--- 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)