From 09c45d91a565642dffefeb87c7b54c4e3224db73 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 12 May 2026 14:24:21 +0200 Subject: [PATCH] lua: add bounds checks for flowints and flowvars Ticket: 8556 (cherry picked from commit 0b239c4848d80b95eef903fec5b718c7e5319f1d) --- src/util-lua-flowintlib.c | 3 +++ src/util-lua-flowvarlib.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/util-lua-flowintlib.c b/src/util-lua-flowintlib.c index 101ae43d5a..8fb7610bc8 100644 --- a/src/util-lua-flowintlib.c +++ b/src/util-lua-flowintlib.c @@ -56,6 +56,9 @@ static int LuaFlowintRegister(lua_State *L) if (*flowvar_id == 0) { return luaL_error(L, "failed to register flowvar"); } + if (ld->flowints >= DETECT_LUA_MAX_FLOWINTS) { + return luaL_error(L, "too many flowints registered"); + } ld->flowint[ld->flowints++] = *flowvar_id; luaL_getmetatable(L, suricata_flowint_mt); diff --git a/src/util-lua-flowvarlib.c b/src/util-lua-flowvarlib.c index 19d15fc9c0..4ad74b4f10 100644 --- a/src/util-lua-flowvarlib.c +++ b/src/util-lua-flowvarlib.c @@ -56,6 +56,9 @@ static int LuaFlowvarRegister(lua_State *L) if (*flowvar_id == 0) { return luaL_error(L, "failed to register flowvar"); } + if (ld->flowvars >= DETECT_LUA_MAX_FLOWVARS) { + return luaL_error(L, "too many flowvars registered"); + } ld->flowvar[ld->flowvars++] = *flowvar_id; luaL_getmetatable(L, suricata_flowvar_mt);