Skip to content

Commit

Permalink
general: disallow mods to remove system commands, refs #275
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform authored and JanSimek committed Apr 2, 2013
1 parent 30fc07e commit c6507d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/client/cl_cgame.c
Expand Up @@ -659,8 +659,7 @@ intptr_t CL_CgameSystemCalls(intptr_t *args)
CL_AddCgameCommand(VMA(1));
return 0;
case CG_REMOVECOMMAND:
// FIXME: NQ/ETPub drop client if Cmd_RemoveCommandSafe is used here
Cmd_RemoveCommand(VMA(1));
Cmd_RemoveCommandSafe(VMA(1));
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand(VMA(1));
Expand Down
28 changes: 12 additions & 16 deletions src/qcommon/cmd.c
Expand Up @@ -364,7 +364,6 @@ void Cmd_Vstr_f(void)
*/
void Cmd_Echo_f(void)
{
int i;
#ifndef DEDICATED
// "cpm" is a cgame command, so just print the text if disconnected
if (cls.state != CA_CONNECTED && cls.state != CA_ACTIVE)
Expand All @@ -373,12 +372,8 @@ void Cmd_Echo_f(void)
return;
}
#endif
Cbuf_AddText("cpm \"");
for (i = 1; i < Cmd_Argc(); i++)
{
Cbuf_AddText(va("%s ", Cmd_Argv(i)));
}
Cbuf_AddText("\"\n");

Cbuf_AddText(va("cpm \"%s\"\n", Cmd_Args()));
}

/*
Expand Down Expand Up @@ -825,13 +820,9 @@ void Cmd_RemoveCommand(const char *cmd_name)
}
}

/*
============
Cmd_RemoveCommandSafe
Only remove commands with no associated function
============
*/
/**
* @brief Only remove commands with no associated function
*/
void Cmd_RemoveCommandSafe(const char *cmd_name)
{
cmd_function_t *cmd = Cmd_FindCommand(cmd_name);
Expand All @@ -842,8 +833,13 @@ void Cmd_RemoveCommandSafe(const char *cmd_name)
}
if (cmd->function)
{
Com_Error(ERR_DROP, "Restricted source tried to remove "
"system command \"%s\"", cmd_name);
// FIXME: NQ/ETPub remove several system command(s), and thus drop the client
//Com_Error(ERR_DROP, "Restricted source tried to remove "
// "system command \"%s\"", cmd_name);

Com_Printf(S_COLOR_RED "Restricted source tried to remove system command \"%s\"\n",
cmd_name);

return;
}

Expand Down

0 comments on commit c6507d5

Please sign in to comment.