]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util: remove malloc from streaming buffer config
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 20 May 2022 18:24:43 +0000 (20:24 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 1 Jun 2022 07:49:39 +0000 (09:49 +0200)
as it is unused

src/app-layer-ftp.c
src/app-layer-htp-body.c
src/app-layer-htp.c
src/stream-tcp-reassemble.c
src/util-streaming-buffer.c
src/util-streaming-buffer.h

index 7bae47df74e733738b578a0365e1821c04017b77..79a7836af6022fce4132826e5660ef5cf53185db 100644 (file)
@@ -1391,7 +1391,6 @@ void RegisterFTPParsers(void)
                 ALPROTO_FTPDATA, FTPDATA_STATE_FINISHED, FTPDATA_STATE_FINISHED);
 
         sbcfg.buf_size = 4096;
-        sbcfg.Malloc = FTPMalloc;
         sbcfg.Calloc = FTPCalloc;
         sbcfg.Realloc = FTPRealloc;
         sbcfg.Free = FTPFree;
index b3042623c28597d4a6f4c9d1c0f6b50cbf35ce13..524aed3578e10beb2f2dc59145388f11a77c27bd 100644 (file)
@@ -63,7 +63,7 @@
 
 #include "util-memcmp.h"
 
-static StreamingBufferConfig default_cfg = { 0, 3072, HTPMalloc, HTPCalloc, HTPRealloc, HTPFree };
+static StreamingBufferConfig default_cfg = { 0, 3072, HTPCalloc, HTPRealloc, HTPFree };
 
 /**
  * \brief Append a chunk of body to the HtpBody struct
index c6cb2bc794f69bffa506b22b1f2dd4b41285b8c9..fc753383730faa9fe71203d2ecaec774953fe11d 100644 (file)
@@ -2538,7 +2538,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec)
     cfg_prec->request.sbcfg.buf_size = cfg_prec->request.inspect_window ?
                                        cfg_prec->request.inspect_window : 256;
     cfg_prec->request.sbcfg.buf_slide = 0;
-    cfg_prec->request.sbcfg.Malloc = HTPMalloc;
     cfg_prec->request.sbcfg.Calloc = HTPCalloc;
     cfg_prec->request.sbcfg.Realloc = HTPRealloc;
     cfg_prec->request.sbcfg.Free = HTPFree;
@@ -2546,7 +2545,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec)
     cfg_prec->response.sbcfg.buf_size = cfg_prec->response.inspect_window ?
                                         cfg_prec->response.inspect_window : 256;
     cfg_prec->response.sbcfg.buf_slide = 0;
-    cfg_prec->response.sbcfg.Malloc = HTPMalloc;
     cfg_prec->response.sbcfg.Calloc = HTPCalloc;
     cfg_prec->response.sbcfg.Realloc = HTPRealloc;
     cfg_prec->response.sbcfg.Free = HTPFree;
index a01d8f72cbc8b3f77505229d0c9e8fd614df0083..3b8b7c3afab58da5638a9056c9bf6744579a694b 100644 (file)
@@ -193,20 +193,6 @@ uint64_t StreamTcpReassembleGetMemcap()
 
 /* memory functions for the streaming buffer API */
 
-/*
-    void *(*Malloc)(size_t size);
-*/
-static void *ReassembleMalloc(size_t size)
-{
-    if (StreamTcpReassembleCheckMemcap(size) == 0)
-        return NULL;
-    void *ptr = SCMalloc(size);
-    if (ptr == NULL)
-        return NULL;
-    StreamTcpReassembleIncrMemuse(size);
-    return ptr;
-}
-
 /*
     void *(*Calloc)(size_t n, size_t size);
 */
@@ -484,7 +470,6 @@ static int StreamTcpReassemblyConfig(bool quiet)
     }
 
     stream_config.sbcnf.buf_size = 2048;
-    stream_config.sbcnf.Malloc = ReassembleMalloc;
     stream_config.sbcnf.Calloc = ReassembleCalloc;
     stream_config.sbcnf.Realloc = StreamTcpReassembleRealloc;
     stream_config.sbcnf.Free = ReassembleFree;
index b60b696f3255a910f74a6c58c437a3fe18b6f7c3..d4c36320379866752d65cf5dbf1f3ddf879a78d1 100644 (file)
@@ -31,8 +31,6 @@
 
 /* memory handling wrappers. If config doesn't define it's own set of
  * functions, use the defaults */
-#define MALLOC(cfg, s) \
-    (cfg)->Malloc ? (cfg)->Malloc((s)) : SCMalloc((s))
 #define CALLOC(cfg, n, s) \
     (cfg)->Calloc ? (cfg)->Calloc((n), (s)) : SCCalloc((n), (s))
 #define REALLOC(cfg, ptr, orig_s, s) \
@@ -909,7 +907,7 @@ static void DumpSegment(StreamingBuffer *sb, StreamingBufferSegment *seg)
 
 static int StreamingBufferTest02(void)
 {
-    StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -965,7 +963,7 @@ static int StreamingBufferTest02(void)
 
 static int StreamingBufferTest03(void)
 {
-    StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1020,7 +1018,7 @@ static int StreamingBufferTest03(void)
 
 static int StreamingBufferTest04(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1111,7 +1109,7 @@ static int StreamingBufferTest04(void)
 /** \test lots of gaps in block list */
 static int StreamingBufferTest06(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1169,7 +1167,7 @@ static int StreamingBufferTest06(void)
 /** \test lots of gaps in block list */
 static int StreamingBufferTest07(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1227,7 +1225,7 @@ static int StreamingBufferTest07(void)
 /** \test lots of gaps in block list */
 static int StreamingBufferTest08(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1285,7 +1283,7 @@ static int StreamingBufferTest08(void)
 /** \test lots of gaps in block list */
 static int StreamingBufferTest09(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
@@ -1343,7 +1341,7 @@ static int StreamingBufferTest09(void)
 /** \test lots of gaps in block list */
 static int StreamingBufferTest10(void)
 {
-    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL };
+    StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL };
     StreamingBuffer *sb = StreamingBufferInit(&cfg);
     FAIL_IF(sb == NULL);
 
index 1680dedf85d506b81982d805080b4f6d2f9ab606..fd2a2e2449c62bf99646a5b267cd013c824a9adc 100644 (file)
@@ -64,7 +64,6 @@
 typedef struct StreamingBufferConfig_ {
     uint32_t buf_slide;
     uint32_t buf_size;
-    void *(*Malloc)(size_t size);
     void *(*Calloc)(size_t n, size_t size);
     void *(*Realloc)(void *ptr, size_t orig_size, size_t size);
     void (*Free)(void *ptr, size_t size);
@@ -72,7 +71,7 @@ typedef struct StreamingBufferConfig_ {
 
 #define STREAMING_BUFFER_CONFIG_INITIALIZER                                                        \
     {                                                                                              \
-        0, 0, NULL, NULL, NULL, NULL,                                                              \
+        0, 0, NULL, NULL, NULL,                                                                    \
     }
 
 /**