]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
fix segfault with long aliases
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index c085aa8856c846bd6b4b34b849b1a03d29591d4f..4e1fb7297885840f42bbb706e960eede4c06a445 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -169,6 +169,11 @@ void Cbuf_Execute (void)
                                break;
                }
 
+               /* should never happen
+               if(i >= MAX_INPUTLINE)
+                       i = MAX_INPUTLINE - 1;
+               */
+
                memcpy (line, text, i);
                line[i] = 0;
 
@@ -413,7 +418,7 @@ static void Cmd_Toggle_f(void)
                }
                else
                { // Invalid CVar
-                       Con_Printf("ERROR : CVar '%s' not found\n", Cmd_Argv(2) );
+                       Con_Printf("ERROR : CVar '%s' not found\n", Cmd_Argv(1) );
                }
        }
 }
@@ -824,12 +829,12 @@ Called for aliases and fills in the alias into the cbuffer
 */
 static void Cmd_ExecuteAlias (cmdalias_t *alias)
 {
-       static char buffer[ MAX_INPUTLINE + 2 ];
-       static char buffer2[ MAX_INPUTLINE * 2 + 2 ];
+       static char buffer[ MAX_INPUTLINE ];
+       static char buffer2[ MAX_INPUTLINE ];
        Cmd_PreprocessString( alias->value, buffer, sizeof(buffer) - 2, alias );
        // insert at start of command buffer, so that aliases execute in order
        // (fixes bug introduced by Black on 20050705)
-       
+
        // Note: Cbuf_PreprocessString will be called on this string AGAIN! So we
        // have to make sure that no second variable expansion takes place, otherwise
        // alias parameters containing dollar signs can have bad effects.