Got_Luacmd: always read netxcmd data, even if command is not executed
This commit is contained in:
parent
3e075e3e4e
commit
531be32abd
1 changed files with 12 additions and 3 deletions
|
|
@ -33,8 +33,18 @@ static consvar_t *this_cvar;
|
|||
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
UINT8 i, argc, flags;
|
||||
const char *argv[256];
|
||||
char buf[256];
|
||||
|
||||
argc = READUINT8(*cp);
|
||||
argv[0] = (const char*)*cp;
|
||||
SKIPSTRINGN(*cp, 255);
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
argv[i] = (const char*)*cp;
|
||||
SKIPSTRINGN(*cp, 255);
|
||||
}
|
||||
|
||||
// don't use I_Assert here, goto the deny code below
|
||||
// to clean up and kick people who try nefarious exploits
|
||||
// like sending random junk lua commands to crash the server
|
||||
|
|
@ -47,8 +57,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
|||
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
|
||||
if (!lua_istable(gL, -1)) goto deny;
|
||||
|
||||
argc = READUINT8(*cp);
|
||||
READSTRINGN(*cp, buf, 255);
|
||||
strlcpy(buf, argv[0], 255);
|
||||
strlwr(buf); // must lowercase buffer
|
||||
lua_getfield(gL, -1, buf); // push command info table
|
||||
if (!lua_istable(gL, -1)) goto deny;
|
||||
|
|
@ -77,7 +86,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
|||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
READSTRINGN(*cp, buf, 255);
|
||||
strlcpy(buf, argv[i], 255);
|
||||
lua_pushstring(gL, buf);
|
||||
}
|
||||
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
|
||||
|
|
|
|||
Loading…
Reference in a new issue