HTP: free TX from transaction free API call

pull/418/merge
Victor Julien 12 years ago
parent 1367074c75
commit 0fd9b0c4fa

@ -303,17 +303,26 @@ void HTPStateFree(void *state)
* \warning We cannot actually free the transactions here. It seems that * \warning We cannot actually free the transactions here. It seems that
* HTP only accepts freeing of transactions in the response callback. * HTP only accepts freeing of transactions in the response callback.
*/ */
void HTPStateTransactionFree(void *state, uint64_t id) { static void HTPStateTransactionFree(void *state, uint64_t id) {
SCEnter(); SCEnter();
HtpState *s = (HtpState *)state; HtpState *s = (HtpState *)state;
s->transaction_done = id;
SCLogDebug("state %p, id %"PRIu64, s, id); SCLogDebug("state %p, id %"PRIu64, s, id);
/* we can't remove the actual transactions here */ htp_tx_t *tx = HTPStateGetTx(s, id);
if (tx != NULL) {
/* This will remove obsolete body chunks */
HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(tx);
if (htud != NULL) {
HtpBodyFree(&htud->request_body);
HtpBodyFree(&htud->response_body);
SCFree(htud);
htp_tx_set_user_data(tx, NULL);
}
SCReturn; htp_tx_destroy(tx);
}
} }
/** /**
@ -2001,27 +2010,6 @@ static int HTPCallbackResponse(htp_connp_t *connp) {
} }
} }
/* remove obsolete transactions */
uint64_t idx;
for (idx = 0; idx < hstate->transaction_done; idx++) {
SCLogDebug("idx %"PRIuMAX, (uintmax_t)idx);
htp_tx_t *tx = HTPStateGetTx(hstate, idx);
if (tx == NULL)
continue;
/* This will remove obsolete body chunks */
HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(tx);
if (htud != NULL) {
HtpBodyFree(&htud->request_body);
HtpBodyFree(&htud->response_body);
SCFree(htud);
htp_tx_set_user_data(tx, NULL);
}
htp_tx_destroy(tx);
}
/* response done, do raw reassembly now to inspect state and stream /* response done, do raw reassembly now to inspect state and stream
* at the same time. */ * at the same time. */
AppLayerTriggerRawStreamReassembly(hstate->f); AppLayerTriggerRawStreamReassembly(hstate->f);

@ -215,7 +215,6 @@ typedef struct HtpState_ {
each connection */ each connection */
Flow *f; /**< Needed to retrieve the original flow when usin HTPLib callbacks */ Flow *f; /**< Needed to retrieve the original flow when usin HTPLib callbacks */
uint64_t transaction_cnt; uint64_t transaction_cnt;
uint64_t transaction_done;
uint64_t store_tx_id; uint64_t store_tx_id;
FileContainer *files_ts; FileContainer *files_ts;
FileContainer *files_tc; FileContainer *files_tc;

Loading…
Cancel
Save