]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fix segv in hcbd and hsbd buffering.
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Fri, 19 Oct 2012 09:40:14 +0000 (15:10 +0530)
committerVictor Julien <victor@inliniac.net>
Sat, 20 Oct 2012 07:29:12 +0000 (09:29 +0200)
Increase bufffers_list_len, only we open up a space for a new tx.

src/detect-engine-hcbd.c
src/detect-engine-hhd.c
src/detect-engine-hsbd.c

index cf0603cb08f607fd8b1441ecfb29c2033b544e97..de1f6635f920fdcee31e9a9bea3cfc73573be1a4 100644 (file)
@@ -93,6 +93,11 @@ static uint8_t *DetectEngineHCBDGetBufferForTX(int tx_id,
         if (HCBDCreateSpace(det_ctx, 1) < 0)
             goto end;
         index = 0;
+
+        if (det_ctx->hcbd_buffers_list_len == 0) {
+            det_ctx->hcbd_start_tx_id = tx_id;
+        }
+        det_ctx->hcbd_buffers_list_len++;
     } else {
         if ((tx_id - det_ctx->hcbd_start_tx_id) < det_ctx->hcbd_buffers_list_len) {
             if (det_ctx->hcbd[(tx_id - det_ctx->hcbd_start_tx_id)].buffer_len != 0) {
@@ -102,15 +107,15 @@ static uint8_t *DetectEngineHCBDGetBufferForTX(int tx_id,
         } else {
             if (HCBDCreateSpace(det_ctx, (tx_id - det_ctx->hcbd_start_tx_id) + 1) < 0)
                 goto end;
+
+            if (det_ctx->hcbd_buffers_list_len == 0) {
+                det_ctx->hcbd_start_tx_id = tx_id;
+            }
+            det_ctx->hcbd_buffers_list_len++;
         }
         index = (tx_id - det_ctx->hcbd_start_tx_id);
     }
 
-    if (det_ctx->hcbd_buffers_list_len == 0) {
-        det_ctx->hcbd_start_tx_id = tx_id;
-    }
-    det_ctx->hcbd_buffers_list_len++;
-
     htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, tx_id);
     if (tx == NULL) {
         SCLogDebug("no tx");
index 814a23daee9b24fdf5a8ab66aa4c182adf00f95a..2e996e2fed73255bd24ff95ce737083d27ea6545 100644 (file)
@@ -96,6 +96,11 @@ static uint8_t *DetectEngineHHDGetBufferForTX(int tx_id,
         if (HHDCreateSpace(det_ctx, 1) < 0)
             goto end;
         index = 0;
+
+        if (det_ctx->hhd_buffers_list_len == 0) {
+            det_ctx->hhd_start_tx_id = tx_id;
+        }
+        det_ctx->hhd_buffers_list_len++;
     } else {
         if ((tx_id - det_ctx->hhd_start_tx_id) < det_ctx->hhd_buffers_list_len) {
             if (det_ctx->hhd_buffers_len[(tx_id - det_ctx->hhd_start_tx_id)] != 0) {
@@ -105,15 +110,15 @@ static uint8_t *DetectEngineHHDGetBufferForTX(int tx_id,
         } else {
             if (HHDCreateSpace(det_ctx, (tx_id - det_ctx->hhd_start_tx_id) + 1) < 0)
                 goto end;
+
+            if (det_ctx->hhd_buffers_list_len == 0) {
+                det_ctx->hhd_start_tx_id = tx_id;
+            }
+            det_ctx->hhd_buffers_list_len++;
         }
         index = (tx_id - det_ctx->hhd_start_tx_id);
     }
 
-    if (det_ctx->hhd_buffers_list_len == 0) {
-        det_ctx->hhd_start_tx_id = tx_id;
-    }
-    det_ctx->hhd_buffers_list_len++;
-
     htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, tx_id);
     if (tx == NULL) {
         SCLogDebug("no tx");
index 9adc9298bbac0d9f089428d231d4d241de30f719..d1d44a5831a53a5718b1f581c2b85d7f481ff213 100644 (file)
@@ -94,6 +94,11 @@ static uint8_t *DetectEngineHSBDGetBufferForTX(int tx_id,
         if (HSBDCreateSpace(det_ctx, 1) < 0)
             goto end;
         index = 0;
+
+        if (det_ctx->hsbd_buffers_list_len == 0) {
+            det_ctx->hsbd_start_tx_id = tx_id;
+        }
+        det_ctx->hsbd_buffers_list_len++;
     } else {
         if ((tx_id - det_ctx->hsbd_start_tx_id) < det_ctx->hsbd_buffers_list_len) {
             if (det_ctx->hsbd[(tx_id - det_ctx->hsbd_start_tx_id)].buffer_len != 0) {
@@ -103,15 +108,15 @@ static uint8_t *DetectEngineHSBDGetBufferForTX(int tx_id,
         } else {
             if (HSBDCreateSpace(det_ctx, (tx_id - det_ctx->hsbd_start_tx_id) + 1) < 0)
                 goto end;
+
+            if (det_ctx->hsbd_buffers_list_len == 0) {
+                det_ctx->hsbd_start_tx_id = tx_id;
+            }
+            det_ctx->hsbd_buffers_list_len++;
         }
         index = (tx_id - det_ctx->hsbd_start_tx_id);
     }
 
-    if (det_ctx->hsbd_buffers_list_len == 0) {
-        det_ctx->hsbd_start_tx_id = tx_id;
-    }
-    det_ctx->hsbd_buffers_list_len++;
-
     htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, tx_id);
     if (tx == NULL) {
         SCLogDebug("no tx");