]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
detect hsbd: simplify resize logic
authorVictor Julien <victor@inliniac.net>
Thu, 18 Jun 2015 10:04:44 +0000 (12:04 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 18 Jun 2015 15:19:44 +0000 (17:19 +0200)
src/detect-engine-hsbd.c

index beba23966bbbdef744120dc89320ff490247ce50..93440a198d72d8944537156576acae24964acc85 100644 (file)
@@ -146,7 +146,6 @@ static void HSBDGetBufferForTXInIPSMode(DetectEngineThreadCtx *det_ctx,
                                         HtpTxUserData *htud, int index)
 {
     uint32_t window_size = 0;
-    int resize = 0;
 
     /* how much from before body_inspected will we consider? */
     uint32_t cfg_win =
@@ -163,10 +162,8 @@ static void HSBDGetBufferForTXInIPSMode(DetectEngineThreadCtx *det_ctx,
         SCLogDebug("weird: body size is %uk", window_size/1024);
         window_size = MAX_WINDOW;
     }
-    if (window_size > det_ctx->hsbd[index].buffer_size)
-        resize = 1;
 
-    if (det_ctx->hsbd[index].buffer == NULL || resize) {
+    if (det_ctx->hsbd[index].buffer == NULL || window_size > det_ctx->hsbd[index].buffer_size) {
         void *ptmp;
 
         if ((ptmp = HTPRealloc(det_ctx->hsbd[index].buffer, det_ctx->hsbd[index].buffer_size, window_size)) == NULL) {
@@ -178,7 +175,6 @@ static void HSBDGetBufferForTXInIPSMode(DetectEngineThreadCtx *det_ctx,
         }
         det_ctx->hsbd[index].buffer = ptmp;
         det_ctx->hsbd[index].buffer_size = window_size;
-        resize = 0;
     }
 
     uint32_t left_edge = htud->response_body.body_inspected - cfg_win;