From f312486c6e7bc35c72b6b7fdaa94ab5ca42c009b Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 22 Apr 2013 17:56:29 +0200 Subject: [PATCH] flowvar/luajit: make 'sets' real time. Needed for cross HTTP-header matching. --- src/detect-luajit-extensions.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/detect-luajit-extensions.c b/src/detect-luajit-extensions.c index 1f8bfea1ba..74b0637cc4 100644 --- a/src/detect-luajit-extensions.c +++ b/src/detect-luajit-extensions.c @@ -165,6 +165,7 @@ int LuajitSetFlowvar(lua_State *luastate) { uint8_t *buffer; DetectEngineThreadCtx *det_ctx; DetectLuajitData *ld; + int need_flow_lock = 0; /* need luajit data for id -> idx conversion */ lua_pushlightuserdata(luastate, (void *)&luaext_key_ld); @@ -199,6 +200,11 @@ int LuajitSetFlowvar(lua_State *luastate) { return 2; } + /* need flow lock hint */ + lua_pushlightuserdata(luastate, (void *)&luaext_key_need_flow_lock); + lua_gettable(luastate, LUA_REGISTRYINDEX); + need_flow_lock = lua_toboolean(luastate, -1); + /* need flowvar idx */ if (!lua_isnumber(luastate, 1)) { lua_pushnil(luastate); @@ -252,15 +258,11 @@ int LuajitSetFlowvar(lua_State *luastate) { memcpy(buffer, str, len); buffer[len] = '\0'; - if (DetectFlowvarStoreMatch(det_ctx, idx, buffer, len, - DETECT_FLOWVAR_TYPE_ALWAYS) < 0) { - SCLogInfo("store failed"); - SCFree(buffer); + if (need_flow_lock) + FlowVarAddStr(f, idx, buffer, len); + else + FlowVarAddStrNoLock(f, idx, buffer, len); - lua_pushnil(luastate); - lua_pushstring(luastate, "store failed"); - return 2; - } //SCLogInfo("stored:"); //PrintRawDataFp(stdout,buffer,len); return 0;