Fix segfault when the protocol is anything other than HTTP

When a file is transferred over anything other than HTTP, the previously hard-coded HTTP protocol would trigger a non-existent index into htp_list_array_get(), causing a segfault. This patch mimics the logic in detect-lua-extensions.c.
pull/3368/head
Elazar Broad 8 years ago committed by Victor Julien
parent 2d2c01e772
commit 6ba02cac50

@ -303,8 +303,6 @@ static int LuaPacketCondition(ThreadVars *tv, const Packet *p)
*
* Executes a script once for one file.
*
* TODO non-http support
*
* NOTE p->flow is locked at this point
*/
static int LuaFileLogger(ThreadVars *tv, void *thread_data, const Packet *p, const File *ff, uint8_t dir)
@ -319,17 +317,16 @@ static int LuaFileLogger(ThreadVars *tv, void *thread_data, const Packet *p, con
SCLogDebug("ff %p", ff);
/* Get the TX so the script can get more context about it.
* TODO hardcoded to HTTP currently */
void *txptr = NULL;
if (p->flow && p->flow->alstate)
txptr = AppLayerParserGetTx(p->proto, ALPROTO_HTTP, p->flow->alstate, ff->txid);
SCMutexLock(&td->lua_ctx->m);
LuaStateSetThreadVars(td->lua_ctx->luastate, tv);
LuaStateSetPacket(td->lua_ctx->luastate, (Packet *)p);
LuaStateSetTX(td->lua_ctx->luastate, txptr);
if (p->flow && p->flow->alstate) {
void *txptr = AppLayerParserGetTx(p->proto, p->flow->alproto, p->flow->alstate, ff->txid);
if (txptr) {
LuaStateSetTX(td->lua_ctx->luastate, txptr);
}
}
LuaStateSetFlow(td->lua_ctx->luastate, p->flow);
LuaStateSetFile(td->lua_ctx->luastate, (File *)ff);

Loading…
Cancel
Save