Fix luajit compilation failure introduced by the transaction update.

Fix coverity lock issues reported by transaction update as well.
pull/370/head
Anoop Saldanha 12 years ago
parent d4d18e3136
commit 7cf4042337

@ -1154,7 +1154,9 @@ void AppLayerTransactionUpdateInspectId(Flow *f, uint8_t flags)
((AppLayerParserStateStore *)f->alparser)->inspect_id[direction] = idx;
if (tx_updated_by > 0) {
SCMutexLock(&f->de_state_m);
DetectEngineStateReset(f->de_state, flags);
SCMutexUnlock(&f->de_state_m);
}
return;

@ -416,6 +416,7 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
DetectEngineStateDirection *dir_state = &f->de_state->dir_state[flags & STREAM_TOSERVER ? 0 : 1];
DeStateStore *store = dir_state->head;
void *inspect_tx = NULL;
uint64_t inspect_tx_id = 0;
uint64_t total_txs = 0;
uint8_t alproto_supports_txs = 0;
@ -423,8 +424,10 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
DeStateResetFileInspection(f, alproto, alstate, flags);
if (AppLayerAlprotoSupportsTxs(alproto)) {
FLOWLOCK_RDLOCK(f);
inspect_tx_id = AppLayerTransactionGetInspectId(f, flags);
total_txs = AppLayerGetTxCnt(alproto, alstate);
FLOWLOCK_UNLOCK(f);
alproto_supports_txs = 1;
}
@ -505,11 +508,9 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
}
engine = app_inspection_engine[alproto][(flags & STREAM_TOSERVER) ? 0 : 1];
void *inspect_tx = AppLayerGetTx(alproto, alstate, inspect_tx_id);
if (inspect_tx == NULL) {
FLOWLOCK_UNLOCK(f);
goto end;
}
inspect_tx = AppLayerGetTx(alproto, alstate, inspect_tx_id);
if (inspect_tx == NULL)
continue;
while (engine != NULL) {
if (!(item->flags & engine->inspect_flags) &&
s->sm_lists[engine->sm_list] != NULL)

@ -48,6 +48,7 @@
#include "util-unittest-helper.h"
#include "app-layer.h"
#include "app-layer-parser.h"
#include "stream-tcp.h"
@ -380,25 +381,21 @@ static int DetectLuajitMatch (ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
FLOWLOCK_RDLOCK(p->flow);
HtpState *htp_state = p->flow->alstate;
if (htp_state != NULL && htp_state->connp != NULL && htp_state->connp->conn != NULL) {
uint64_t idx = AppLayerTransactionGetInspectId(p->flow, flags);
if (idx != -1) {
htp_tx_t *tx = NULL;
uint64_t total_txs= AppLayerGetNoOfTxs(ALPROTO_HTTP, htp_state);
for ( ; idx < size; idx++)
{
tx = AppLayerGetTx(http_state, idx);
if (tx == NULL)
continue;
if ((tluajit->flags & DATATYPE_HTTP_REQUEST_LINE) && tx->request_line != NULL &&
bstr_len(tx->request_line) > 0) {
lua_pushliteral(tluajit->luastate, "http.request_line"); /* stack at -2 */
lua_pushlstring (tluajit->luastate,
(const char *)bstr_ptr(tx->request_line),
bstr_len(tx->request_line));
lua_settable(tluajit->luastate, -3);
}
htp_tx_t *tx = NULL;
uint64_t idx = AppLayerTransactionGetInspectId(p->flow, 0);
uint64_t total_txs= AppLayerGetTxCnt(ALPROTO_HTTP, htp_state);
for ( ; idx < total_txs; idx++) {
tx = AppLayerGetTx(ALPROTO_HTTP, htp_state, idx);
if (tx == NULL)
continue;
if ((tluajit->flags & DATATYPE_HTTP_REQUEST_LINE) && tx->request_line != NULL &&
bstr_len(tx->request_line) > 0) {
lua_pushliteral(tluajit->luastate, "http.request_line"); /* stack at -2 */
lua_pushlstring (tluajit->luastate,
(const char *)bstr_ptr(tx->request_line),
bstr_len(tx->request_line));
lua_settable(tluajit->luastate, -3);
}
}
}

Loading…
Cancel
Save