Skip to content

Commit

Permalink
lua: remove internal references to luajit
Browse files Browse the repository at this point in the history
  • Loading branch information
J0eJ0h committed Jan 26, 2024
1 parent a6c8da9 commit ff0438e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/detect-lua-extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static int GetFlowVarById(lua_State *luastate, Flow *f,
LUA_ERROR("flowvar id not a number");
}
int id = lua_tonumber(luastate, 1);
if (id < 0 || id >= DETECT_LUAJIT_MAX_FLOWVARS) {
if (id < 0 || id >= DETECT_LUA_MAX_FLOWVARS) {
LUA_ERROR("flowvar id out of range");
}
uint32_t idx = ld->flowvar[id];
Expand Down Expand Up @@ -185,7 +185,7 @@ static int GetFlowIntById(lua_State *luastate, Flow *f,
LUA_ERROR("flowvar id not a number");
}
int id = lua_tonumber(luastate, 1);
if (id < 0 || id >= DETECT_LUAJIT_MAX_FLOWVARS) {
if (id < 0 || id >= DETECT_LUA_MAX_FLOWVARS) {
LUA_ERROR("flowvar id out of range");
}
uint32_t idx = ld->flowint[id];
Expand Down Expand Up @@ -391,7 +391,7 @@ static int LuaSetFlowint(lua_State *luastate)
LUA_ERROR("1st arg not a number");
}
int id = lua_tonumber(luastate, 1);
if (id < 0 || id >= DETECT_LUAJIT_MAX_FLOWVARS) {
if (id < 0 || id >= DETECT_LUA_MAX_FLOWVARS) {
LUA_ERROR("flowint id out of range");
}

Expand Down Expand Up @@ -496,7 +496,7 @@ static int LuaGetByteVar(lua_State *luastate)
LUA_ERROR("bytevar id not a number");
}
int id = lua_tonumber(luastate, 1);
if (id < 0 || id >= DETECT_LUAJIT_MAX_BYTEVARS) {
if (id < 0 || id >= DETECT_LUA_MAX_BYTEVARS) {
LUA_ERROR("bytevar id out of range");
}
uint32_t idx = ld->bytevar[id];
Expand Down
10 changes: 4 additions & 6 deletions src/detect-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

static int DetectLuaSetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c)
{
SCLogError("no Lua support built in, needed for lua/luajit keyword");
SCLogError("no Lua support built in, needed for lua keyword");
return -1;
}

Expand All @@ -77,7 +77,6 @@ static int DetectLuaSetupNoSupport (DetectEngineCtx *a, Signature *b, const char
void DetectLuaRegister(void)
{
sigmatch_table[DETECT_LUA].name = "lua";
sigmatch_table[DETECT_LUA].alias = "luajit";
sigmatch_table[DETECT_LUA].desc = "support for lua scripting";
sigmatch_table[DETECT_LUA].url = "/rules/rule-lua-scripting.html";
sigmatch_table[DETECT_LUA].Setup = DetectLuaSetupNoSupport;
Expand Down Expand Up @@ -111,7 +110,6 @@ static int g_smtp_generic_list_id = 0;
void DetectLuaRegister(void)
{
sigmatch_table[DETECT_LUA].name = "lua";
sigmatch_table[DETECT_LUA].alias = "luajit";
sigmatch_table[DETECT_LUA].desc = "match via a lua script";
sigmatch_table[DETECT_LUA].url = "/rules/rule-lua-scripting.html";
sigmatch_table[DETECT_LUA].Match = DetectLuaMatch;
Expand Down Expand Up @@ -786,7 +784,7 @@ static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuaData *ld, const
/* removes 'value'; keeps 'key' for next iteration */
lua_pop(luastate, 1);

if (ld->flowvars == DETECT_LUAJIT_MAX_FLOWVARS) {
if (ld->flowvars == DETECT_LUA_MAX_FLOWVARS) {
SCLogError("too many flowvars registered");
goto error;
}
Expand All @@ -808,7 +806,7 @@ static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuaData *ld, const
/* removes 'value'; keeps 'key' for next iteration */
lua_pop(luastate, 1);

if (ld->flowints == DETECT_LUAJIT_MAX_FLOWINTS) {
if (ld->flowints == DETECT_LUA_MAX_FLOWINTS) {
SCLogError("too many flowints registered");
goto error;
}
Expand All @@ -830,7 +828,7 @@ static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuaData *ld, const
/* removes 'value'; keeps 'key' for next iteration */
lua_pop(luastate, 1);

if (ld->bytevars == DETECT_LUAJIT_MAX_BYTEVARS) {
if (ld->bytevars == DETECT_LUA_MAX_BYTEVARS) {
SCLogError("too many bytevars registered");
goto error;
}
Expand Down
12 changes: 6 additions & 6 deletions src/detect-lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ typedef struct DetectLuaThreadData {
int alproto;
} DetectLuaThreadData;

#define DETECT_LUAJIT_MAX_FLOWVARS 15
#define DETECT_LUAJIT_MAX_FLOWINTS 15
#define DETECT_LUAJIT_MAX_BYTEVARS 15
#define DETECT_LUA_MAX_FLOWVARS 15
#define DETECT_LUA_MAX_FLOWINTS 15
#define DETECT_LUA_MAX_BYTEVARS 15

typedef struct DetectLuaData {
int thread_ctx_id;
Expand All @@ -45,12 +45,12 @@ typedef struct DetectLuaData {
uint32_t flags;
AppProto alproto;
char *buffername; /* buffer name in case of a single buffer */
uint32_t flowint[DETECT_LUAJIT_MAX_FLOWINTS];
uint32_t flowint[DETECT_LUA_MAX_FLOWINTS];
uint16_t flowints;
uint16_t flowvars;
uint32_t flowvar[DETECT_LUAJIT_MAX_FLOWVARS];
uint32_t flowvar[DETECT_LUA_MAX_FLOWVARS];
uint16_t bytevars;
uint32_t bytevar[DETECT_LUAJIT_MAX_BYTEVARS];
uint32_t bytevar[DETECT_LUA_MAX_BYTEVARS];
uint32_t sid;
uint32_t rev;
uint32_t gid;
Expand Down

0 comments on commit ff0438e

Please sign in to comment.