]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
HTP: free TX from transaction free API call
authorVictor Julien <victor@inliniac.net>
Tue, 2 Jul 2013 10:51:42 +0000 (12:51 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 4 Jul 2013 11:52:13 +0000 (13:52 +0200)
src/app-layer-htp.c
src/app-layer-htp.h

index a8e55618e43c8a4e0cc4531815e182302b64a75d..7908806dea59568c9480b8e27c1500dc8b42fd43 100644 (file)
@@ -303,17 +303,26 @@ void HTPStateFree(void *state)
  *  \warning We cannot actually free the transactions here. It seems that
  *           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();
 
     HtpState *s = (HtpState *)state;
 
-    s->transaction_done = 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
      * at the same time. */
     AppLayerTriggerRawStreamReassembly(hstate->f);
index f12a1e55c73e218e679f7caa06e810756ceb7727..d9ea8352db63b84eddb1d8df08ea2241e365b7cf 100644 (file)
@@ -215,7 +215,6 @@ typedef struct HtpState_ {
                                  each connection */
     Flow *f;                /**< Needed to retrieve the original flow when usin HTPLib callbacks */
     uint64_t transaction_cnt;
-    uint64_t transaction_done;
     uint64_t store_tx_id;
     FileContainer *files_ts;
     FileContainer *files_tc;