Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MAX_CONSOLE_LENGTH and COMMAND_MAX_* defines to console.inc #1732

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions core/logic/smn_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <bridge/include/CoreProvider.h>
#include <bridge/include/IVEngineServerBridge.h>

static constexpr unsigned MAX_CONSOLE_LENGTH = 1024; // paired to MAX_CONSOLE_LENGTH in console.inc

static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
{
if (params[1] == 0)
Expand Down Expand Up @@ -88,7 +90,7 @@ static cell_t CheckAccess(IPluginContext *pContext, const cell_t *params)

static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
{
char buffer[1024];
char buffer[MAX_CONSOLE_LENGTH];
char *fmt;
int arg = 2;

Expand Down Expand Up @@ -129,7 +131,7 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)

g_pSM->SetGlobalTarget(index);

char buffer[1024];
char buffer[MAX_CONSOLE_LENGTH];
char *fmt;
int arg = 3;

Expand All @@ -154,7 +156,7 @@ static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);

char buffer[1024];
char buffer[MAX_CONSOLE_LENGTH];
size_t len;
{
DetectExceptions eh(pContext);
Expand All @@ -176,7 +178,7 @@ static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *par
{
g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);

char buffer[1024];
char buffer[MAX_CONSOLE_LENGTH];
size_t len;
{
DetectExceptions eh(pContext);
Expand Down Expand Up @@ -265,7 +267,7 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
g_pSM->SetGlobalTarget(params[1]);

/* Build the format string */
char buffer[1024];
char buffer[MAX_CONSOLE_LENGTH];
size_t len;
{
DetectExceptions eh(pContext);
Expand Down Expand Up @@ -338,19 +340,19 @@ static cell_t RemoveServerTag(IPluginContext *pContext, const cell_t *params)

REGISTER_NATIVES(consoleNatives)
{
{"CheckCommandAccess", CheckCommandAccess},
{"CheckAccess", CheckAccess},
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{"ServerCommand", sm_ServerCommand},
{"InsertServerCommand", sm_InsertServerCommand},
{"ServerExecute", sm_ServerExecute},
{"ClientCommand", sm_ClientCommand},
{"FakeClientCommand", FakeClientCommand},
{"ReplyToCommand", ReplyToCommand},
{"GetCmdReplySource", GetCmdReplyTarget},
{"SetCmdReplySource", SetCmdReplyTarget},
{"AddServerTag", AddServerTag},
{"RemoveServerTag", RemoveServerTag},
{NULL, NULL}
{"CheckCommandAccess", CheckCommandAccess},
{"CheckAccess", CheckAccess},
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{"ServerCommand", sm_ServerCommand},
{"InsertServerCommand", sm_InsertServerCommand},
{"ServerExecute", sm_ServerExecute},
{"ClientCommand", sm_ClientCommand},
{"FakeClientCommand", FakeClientCommand},
{"ReplyToCommand", ReplyToCommand},
{"GetCmdReplySource", GetCmdReplyTarget},
{"SetCmdReplySource", SetCmdReplyTarget},
{"AddServerTag", AddServerTag},
{"RemoveServerTag", RemoveServerTag},
{NULL, NULL}
};
5 changes: 5 additions & 0 deletions plugins/include/console.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@

#define INVALID_FCVAR_FLAGS (-1)

#define MAX_CONSOLE_LENGTH 1024 /**< Maximum buffer size for console messages */

#define COMMAND_MAX_ARGC 64 /**< Maxmimum allowed command argument count */
#define COMMAND_MAX_LENGTH 512 /**< Maxmimum allowed length of a command argument */

/**
* Console variable query helper values.
*/
Expand Down