From: Jason Ish Date: Tue, 29 Apr 2025 17:26:46 +0000 (-0600) Subject: lua/flowvarlib: fix unchecked null X-Git-Tag: suricata-8.0.0-rc1~402 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=096aa9250edf735b0183a4f439b42cc975e4f17f;p=thirdparty%2Fsuricata.git lua/flowvarlib: fix unchecked null Use checkudata, instead of testudata which won't return in case of NULL, but raise an error in the Lua script. Fixes: ** CID 1646748: Null pointer dereferences (NULL_RETURNS) /src/util-lua-flowvarlib.c: 89 in LuaFlowvarValue() --- diff --git a/src/util-lua-flowvarlib.c b/src/util-lua-flowvarlib.c index 5d49b52ae4..9d80d349bb 100644 --- a/src/util-lua-flowvarlib.c +++ b/src/util-lua-flowvarlib.c @@ -81,7 +81,7 @@ static int LuaFlowvarGet(lua_State *L) static int LuaFlowvarValue(lua_State *L) { - uint32_t *flowvar_id = luaL_testudata(L, 1, suricata_flowvar_mt); + uint32_t *flowvar_id = luaL_checkudata(L, 1, suricata_flowvar_mt); Flow *f = LuaStateGetFlow(L); if (f == NULL) { return LuaCallbackError(L, "flow is NULL");