]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #676 in SNORT/snort3 from catch to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 14 Oct 2016 17:31:44 +0000 (13:31 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 14 Oct 2016 17:31:44 +0000 (13:31 -0400)
Squashed commit of the following:

commit c91b18f82800a36a2369528a5b5df019696da0cd
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 12:09:27 2016 -0400

    fix trace catch test new[]/delete mismatch

commit f6b4a07bf30bb1c93a3c301999d83232d9185582
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 11:55:13 2016 -0400

    fix SFDAQModule catch test leaks

commit e61d1f8f4e724ff7cc0bfe72184f56ee8859cb3b
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 10:15:11 2016 -0400

    fix sfrf and sfthd catch test policy issues

commit cf018e1603636903f9e6f53aad3e306905ade18c
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 09:36:47 2016 -0400

    fix sfrf catch test leaks

commit ea3c46be4719f291da1998e12863989531e2ceeb
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 09:15:59 2016 -0400

    fix vars catch test leaks

commit 2d08ef2e1cddd1c549d4700a16ffbbcb32739d95
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 08:52:38 2016 -0400

    fix ThreadConfig catch test leaks

commit 5ce152f0468a878fb2156c20cdb5cc18b7a8af18
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 08:44:07 2016 -0400

    fix sfthd catch test leaks

commit ecad5dcafe699c9379b92c97cc90c24fc7cfbd76
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 07:53:38 2016 -0400

    fix ips_stream_reassemble catch test leaks

commit e8d34f1a04318097f0704b1ba8102854666ca1f1
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 14 07:51:39 2016 -0400

    fix file_decomp catch test leaks

13 files changed:
src/decompress/file_decomp.cc
src/decompress/file_decomp_pdf.cc
src/decompress/file_decomp_swf.cc
src/filters/sfrf_test.cc
src/filters/sfthd.cc
src/filters/sfthd.h
src/filters/sfthd_test.cc
src/main/snort_debug.cc
src/main/thread_config.cc
src/packet_io/sfdaq_module.cc
src/packet_io/test/sfdaq_module_test.cc
src/parser/vars.cc
src/stream/tcp/ips_stream_reassemble.cc

index 420e245a7611917ed229069aac4dcd20b4b63b01..036cbc96a3c0ee9614f50813b87393cfa6392296 100644 (file)
@@ -485,6 +485,7 @@ TEST_CASE("File_Decomp_SetBuf-Decompr_Depth-error", "[file_decomp]")
     p_s->Total_Out = 20;
     p_s->Decompr_Depth = 10;
     REQUIRE(File_Decomp_SetBuf(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("File_Decomp_SetBuf-Compr_Depth-error", "[file_decomp]")
@@ -495,6 +496,7 @@ TEST_CASE("File_Decomp_SetBuf-Compr_Depth-error", "[file_decomp]")
     p_s->Total_In = 20;
     p_s->Compr_Depth = 10;
     REQUIRE(File_Decomp_SetBuf(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("File_Decomp_New", "[file_decomp]")
@@ -510,6 +512,7 @@ TEST_CASE("File_Decomp_New", "[file_decomp]")
     REQUIRE(p_s->Avail_Out == 0);
     REQUIRE(p_s->Next_In == NULL);
     REQUIRE(p_s->Next_Out == NULL);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("File_Decomp-null", "[file_decomp]")
@@ -523,6 +526,7 @@ TEST_CASE("File_Decomp-not_active", "[file_decomp]")
 
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
     REQUIRE(File_Decomp(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("File_Decomp-complete_state", "[file_decomp]")
@@ -532,6 +536,7 @@ TEST_CASE("File_Decomp-complete_state", "[file_decomp]")
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
     p_s->State = STATE_COMPLETE;
     REQUIRE(File_Decomp(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("Initialize_Decompression-not_active", "[file_decomp]")
@@ -540,6 +545,7 @@ TEST_CASE("Initialize_Decompression-not_active", "[file_decomp]")
 
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
     REQUIRE(Initialize_Decompression(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 TEST_CASE("Process_Decompression-not_active", "[file_decomp]")
@@ -548,6 +554,7 @@ TEST_CASE("Process_Decompression-not_active", "[file_decomp]")
 
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
     REQUIRE(Process_Decompression(p_s) == File_Decomp_Error);
+    File_Decomp_Free(p_s);
 }
 
 #endif
index a7d0399a5c7b7cf0f8edb9b7c47a0520105a3e67..d5295fba705d8c69d314f32c016f5de17ac6dcef 100644 (file)
@@ -1156,22 +1156,22 @@ fd_status_t File_Decomp_PDF(fd_session_p_t SessionPtr)
 
 #ifdef UNIT_TEST
 
-TEST_CASE("File_Decomp_PDF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_PDF-null", "[file_decomp_pdf]")
 {
     REQUIRE(File_Decomp_PDF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_Init_PDF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_Init_PDF-null", "[file_decomp_pdf]")
 {
     REQUIRE(File_Decomp_Init_PDF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_End_PDF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_End_PDF-null", "[file_decomp_pdf]")
 {
     REQUIRE(File_Decomp_End_PDF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_PDF-not_pdf-error", "[file_decomp]")
+TEST_CASE("File_Decomp_PDF-not_pdf-error", "[file_decomp_pdf]")
 {
     fd_session_p_t p_s;
 
@@ -1179,10 +1179,11 @@ TEST_CASE("File_Decomp_PDF-not_pdf-error", "[file_decomp]")
     p_s->PDF = (fd_PDF_t*)snort_calloc(sizeof(fd_PDF_t));
     p_s->File_Type = FILE_TYPE_SWF;
     REQUIRE(File_Decomp_PDF(p_s) == File_Decomp_Error);
-    snort_free(p_s->PDF);
+    p_s->File_Type = FILE_TYPE_PDF;
+    File_Decomp_Free(p_s);
 }
 
-TEST_CASE("File_Decomp_PDF-bad_state-error", "[file_decomp]")
+TEST_CASE("File_Decomp_PDF-bad_state-error", "[file_decomp_pdf]")
 {
     fd_session_p_t p_s;
 
@@ -1191,19 +1192,20 @@ TEST_CASE("File_Decomp_PDF-bad_state-error", "[file_decomp]")
     p_s->File_Type = FILE_TYPE_PDF;
     p_s->PDF->State = PDF_STATE_NEW;
     REQUIRE(File_Decomp_PDF(p_s) == File_Decomp_Error);
-    snort_free(p_s->PDF);
+    File_Decomp_Free(p_s);
 }
 
-TEST_CASE("File_Decomp_End_PDF-bad_type-error", "[file_decomp]")
+TEST_CASE("File_Decomp_End_PDF-bad_type-error", "[file_decomp_pdf]")
 {
     fd_session_p_t p_s;
 
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
     p_s->PDF = (fd_PDF_t*)snort_calloc(sizeof(fd_PDF_t));
+    p_s->File_Type = FILE_TYPE_PDF;
     p_s->PDF->Decomp_Type = FILE_COMPRESSION_TYPE_LZMA;
     p_s->PDF->State = PDF_STATE_PROCESS_STREAM;
     REQUIRE(File_Decomp_End_PDF(p_s) == File_Decomp_Error);
-    snort_free(p_s->PDF);
+    File_Decomp_Free(p_s);
 }
 
 #endif
index d120258420934516c47755a3cb38a269fecacdc4..6b534b8f05f39ba1bde4bc7ed8682d47240684d3 100644 (file)
@@ -346,22 +346,22 @@ fd_status_t File_Decomp_SWF(fd_session_p_t SessionPtr)
 
 #ifdef UNIT_TEST
 
-TEST_CASE("File_Decomp_SWF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_SWF-null", "[file_decomp_swf]")
 {
     REQUIRE(File_Decomp_SWF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_Init_SWF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_Init_SWF-null", "[file_decomp_swf]")
 {
     REQUIRE(File_Decomp_Init_SWF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_End_SWF-null", "[file_decomp]")
+TEST_CASE("File_Decomp_End_SWF-null", "[file_decomp_swf]")
 {
     REQUIRE(File_Decomp_End_SWF((fd_session_p_t)NULL) == File_Decomp_Error);
 }
 
-TEST_CASE("File_Decomp_SWF-not_swf-error", "[file_decomp]")
+TEST_CASE("File_Decomp_SWF-not_swf-error", "[file_decomp_swf]")
 {
     fd_session_p_t p_s;
 
@@ -369,10 +369,11 @@ TEST_CASE("File_Decomp_SWF-not_swf-error", "[file_decomp]")
     p_s->SWF = (fd_SWF_t*)snort_calloc(sizeof(fd_SWF_t));
     p_s->File_Type = FILE_TYPE_PDF;
     REQUIRE(File_Decomp_SWF(p_s) == File_Decomp_Error);
-    snort_free(p_s->SWF);
+    p_s->File_Type = FILE_TYPE_SWF;
+    File_Decomp_Free(p_s);
 }
 
-TEST_CASE("File_Decomp_SWF-bad_state-error", "[file_decomp]")
+TEST_CASE("File_Decomp_SWF-bad_state-error", "[file_decomp_swf]")
 {
     fd_session_p_t p_s;
 
@@ -381,21 +382,21 @@ TEST_CASE("File_Decomp_SWF-bad_state-error", "[file_decomp]")
     p_s->File_Type = FILE_TYPE_SWF;
     p_s->SWF->State = SWF_STATE_NEW;
     REQUIRE(File_Decomp_SWF(p_s) == File_Decomp_Error);
-    snort_free(p_s->SWF);
+    File_Decomp_Free(p_s);
 }
 
-TEST_CASE("File_Decomp_Init_SWF-bad_type-error", "[file_decomp]")
+TEST_CASE("File_Decomp_Init_SWF-bad_type-error", "[file_decomp_swf]")
 {
     fd_session_p_t p_s;
 
     REQUIRE((p_s = File_Decomp_New()) != (fd_session_p_t)NULL);
-    p_s->SWF = (fd_SWF_t*)snort_calloc(sizeof(fd_SWF_t));
+    p_s->File_Type = FILE_TYPE_SWF;
     p_s->Decomp_Type = FILE_COMPRESSION_TYPE_DEFLATE;
     REQUIRE(File_Decomp_Init_SWF(p_s) == File_Decomp_Error);
-    snort_free(p_s->SWF);
+    File_Decomp_Free(p_s);
 }
 
-TEST_CASE("File_Decomp_End_SWF-bad_type-error", "[file_decomp]")
+TEST_CASE("File_Decomp_End_SWF-bad_type-error", "[file_decomp_swf]")
 {
     fd_session_p_t p_s;
 
@@ -403,7 +404,9 @@ TEST_CASE("File_Decomp_End_SWF-bad_type-error", "[file_decomp]")
     p_s->SWF = (fd_SWF_t*)snort_calloc(sizeof(fd_SWF_t));
     p_s->Decomp_Type = FILE_COMPRESSION_TYPE_DEFLATE;
     REQUIRE(File_Decomp_End_SWF(p_s) == File_Decomp_Error);
-    snort_free(p_s->SWF);
+    p_s->File_Type = FILE_TYPE_SWF;
+    File_Decomp_Free(p_s);
 }
 
+
 #endif
index 8f7427f5a544e0cbd6745a97230cd08b82bae445..06e5771cecf944d7bfa5a70b4bf2c59ab049d17e 100644 (file)
 
 #include "catch/catch.hpp"
 
-#include "main/snort_types.h"
-#include "main/snort_config.h"
 #include "detection/rules.h"
 #include "detection/treenodes.h"
-#include "sfip/sf_ip.h"
-#include "parser/parse_ip.h"
+#include "filters/rate_filter.h"
 #include "filters/sfrf.h"
-#include "utils/util.h"
 #include "hash/sfghash.h"
+#include "main/snort_types.h"
+#include "main/policy.h"
+#include "parser/parse_ip.h"
+#include "sfip/sf_ip.h"
+#include "utils/util.h"
 
 //---------------------------------------------------------------
 
@@ -85,7 +86,7 @@ typedef struct
     int expect;
 } EventData;
 
-static RateFilterConfig rfc;
+static RateFilterConfig* rfc = nullptr;
 
 //---------------------------------------------------------------
 
@@ -891,19 +892,21 @@ static void PrintTests()
     }
     exit(0);
 }
-
 #endif
 
 //---------------------------------------------------------------
 
 static void Init(unsigned cap)
 {
-    unsigned i;
-
-    memset(&rfc, 0, sizeof(rfc));
-    rfc.memcap = cap;
-
-    for ( i = 0; i < NUM_NODES; i++ )
+    // FIXIT-L must set policies because they may have been invalidated
+    // by prior tests with transient SnortConfigs.  better to fix sfrf
+    // to use a SnortConfig parameter or make this a make check test
+    // with a separate executable.
+    set_default_policy();
+    rfc = RateFilter_ConfigNew();
+    rfc->memcap = cap;
+
+    for ( unsigned i = 0; i < NUM_NODES; i++ )
     {
         RateData* p = rfData + i;
         tSFRFConfigNode cfg;
@@ -917,22 +920,15 @@ static void Init(unsigned cap)
         cfg.timeout = p->timeout;
         cfg.applyTo = p->ip ? sfip_var_from_string(p->ip) : NULL;
 
-        p->create = SFRF_ConfigAdd(snort_conf, &rfc, &cfg);
+        p->create = SFRF_ConfigAdd(nullptr, rfc, &cfg);
     }
 }
 
 static void Term()
 {
-    int i;
-
-    for (i = 0; i < SFRF_MAX_GENID; i++)
-    {
-        SFGHASH** h = rfc.genHash + i;
-        if ( *h )
-            sfghash_delete(*h);
-        *h = NULL;
-    }
     SFRF_Delete();
+    RateFilter_ConfigFree(rfc);
+    rfc = nullptr;
 }
 
 static int SetupCheck(int i)
@@ -959,7 +955,7 @@ static int EventTest(EventData* p)
     sfip_pton(p->dip, &dip);
 
     status = SFRF_TestThreshold(
-        &rfc, p->gid, p->sid, &sip, &dip, curtime, op);
+        rfc, p->gid, p->sid, &sip, &dip, curtime, op);
 
     if ( status >= RULE_TYPE__MAX )
         status -= RULE_TYPE__MAX;
index 2a444777be1436a2e06d3c07a9e4af29a562f9c7..c1e88336d0789bf932784d6e5506fde6ae0a0c84 100644 (file)
@@ -160,7 +160,7 @@ ThresholdObjects* sfthd_objs_new()
     return (ThresholdObjects*)snort_calloc(sizeof(ThresholdObjects));
 }
 
-static void sfthd_node_free(void* node)
+void sfthd_node_free(void* node)
 {
     THD_NODE* sfthd_node = (THD_NODE*)node;
 
index 3e3248ab06d54899b6fb68d33419ab047ee5fc3a..e5670865047796566c72d10dc1975eeb877e3046 100644 (file)
@@ -226,6 +226,7 @@ void* sfthd_create_rule_threshold(
     int count,
     unsigned int seconds
     );
+void sfthd_node_free(void*);
 
 struct SnortConfig;
 int sfthd_create_threshold(
index 6c2f404df7618d9b59ac68f9a62023bf9c0606d5..083501ae9c64f87aeb517caf44b553320f46fd6f 100644 (file)
 
 #include "catch/catch.hpp"
 
-#include "sfip/sf_ip.h"
-#include "parser/parse_ip.h"
 #include "filters/sfthd.h"
+#include "hash/sfxhash.h"
+#include "main/policy.h"
+#include "parser/parse_ip.h"
+#include "sfip/sf_ip.h"
 #include "utils/util.h"
-#include "main/snort_config.h"
 
 //---------------------------------------------------------------
 
@@ -740,6 +741,12 @@ static EventData pktData[] =
 
 static void Init(ThreshData* base, int max)
 {
+    // FIXIT-L must set policies because they may have been invalidated
+    // by prior tests with transient SnortConfigs.  better to fix sfthd
+    // to use a SnortConfig parameter or make this a make check test
+    // with a separate executable.
+    set_default_policy();
+
     int i;
     int id = 0;
 
@@ -751,7 +758,7 @@ static void Init(ThreshData* base, int max)
         {
             sfip_var_t* set = p->ip ? sfip_var_from_string(p->ip) : NULL;
 
-            p->create = sfthd_create_threshold(snort_conf,
+            p->create = sfthd_create_threshold(nullptr,
                 pThdObjs, p->gid, p->sid, p->tracking, p->type, PRIORITY,
                 p->count, p->seconds, set);
 
@@ -790,6 +797,18 @@ static void Term()
     pThdObjs = NULL;
     sfthd_free(pThd);
     pThd = NULL;
+
+    for ( unsigned i = 0; i < NUM_RULS; i++ )
+    {
+        ThreshData* p = ruleData + i;
+
+        if ( p->rule )
+        {
+            sfthd_node_free(p->rule);
+            p->rule = nullptr;
+        }
+    }
+    sfxhash_delete(dThd);
 }
 
 static int SetupCheck(int i)
index 4c4fb00554daeba52349ef0fa9c4618ff888be88..f644fd5f29e44ad308b807917f61275f492b5d7e 100644 (file)
@@ -286,8 +286,7 @@ TEST_CASE("trace_debugf", "[trace]")
 TEST_CASE("safety", "[trace]")
 {
     Trace TRACE_NAME(testing) = TRACE_SECTION_2 | TRACE_SECTION_3;
-    
-    char* message = new char[STD_BUF + 1];
+    char message[STD_BUF + 1];
 
     for( int i = 0; i < STD_BUF; i++ )
         message[i] = 'A';
@@ -296,8 +295,7 @@ TEST_CASE("safety", "[trace]")
     testing_dump[0] = '\0';
     trace_log(testing, message);
     CHECK( strlen(testing_dump) == STD_BUF - 1 );
-
-    delete message;
 }
 
 #endif
+
index 01861b0fce738099e51395d5cc418376340b4881..6cb9d492eaca4b4f831eec8c2af6274da995bc5b 100644 (file)
@@ -219,6 +219,8 @@ TEST_CASE("Set and implement thread affinity", "[ThreadConfig]")
         tc.implement_thread_affinity(STHREAD_TYPE_MAIN, 0);
         hwloc_get_cpubind(topology, thread_cpuset, HWLOC_CPUBIND_THREAD);
         CHECK(hwloc_bitmap_isequal(thread_cpuset, process_cpuset));
+
+        hwloc_bitmap_free(thread_cpuset);
     }
 }
 
index c49c89943c2e95538e44a7024c548d63fb9069f6..b1f537fc9553cff647da0a3c54c95738bc75eaeb 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "sfdaq_module.h"
 
+#include <assert.h>
+
 #include "log/messages.h"
 #include "main/snort_config.h"
 
@@ -78,14 +80,17 @@ bool SFDAQModule::begin(const char* fqn, int idx, SnortConfig*)
 {
     if (!strcmp(fqn, "daq"))
         config = new SFDAQConfig();
+
     else if (!strcmp(fqn, "daq.instances"))
     {
         if (idx == 0)
             return true;
+
+        assert(!instance_config);
         instance_config = new SFDAQInstanceConfig();
+
         instance_id = -1;
     }
-
     return true;
 }
 
@@ -137,9 +142,12 @@ bool SFDAQModule::end(const char* fqn, int idx, SnortConfig* sc)
     {
         if (idx == 0)
             return true;
-        if (instance_id < 0)
+
+        if (instance_id < 0 or config->instances[instance_id])
         {
-            ParseError("%s - no DAQ instance ID specified", fqn);
+            ParseError("%s - duplicate or no DAQ instance ID specified", fqn);
+            delete instance_config;
+            instance_config = nullptr;
             return false;
         }
         config->instances[instance_id] = instance_config;
@@ -149,6 +157,7 @@ bool SFDAQModule::end(const char* fqn, int idx, SnortConfig* sc)
     {
         if ( sc->daq_config )
             delete sc->daq_config;
+
         sc->daq_config = config;
         config = nullptr;
     }
index 5b130651584a7cc1e4a778d34b3b7940f1652e9a..9c798451b927f63a8a632b9130f8f2207f69d538 100644 (file)
@@ -56,10 +56,11 @@ TEST_CASE("Kitchen Sink", "[SFDAQModule]")
     Value no_promisc(true);
     CHECK(sfdm.set("daq.no_promisc", no_promisc, &sc));
 
+    CHECK(sfdm.begin("daq.instances", 0, &sc));
     CHECK(sfdm.begin("daq.instances", 1, &sc));
-    CHECK_FALSE(sfdm.end("daq.instances", 1, &sc));
 
-    CHECK(sfdm.begin("daq.instances", 1, &sc));
+    CHECK_FALSE(sfdm.end("daq.instances", 1, &sc));
+    CHECK(sfdm.begin("daq.instances", 2, &sc));
 
     Value instance_id(static_cast<double>(5));
     CHECK(sfdm.set("daq.instances.id", instance_id, &sc));
@@ -72,7 +73,8 @@ TEST_CASE("Kitchen Sink", "[SFDAQModule]")
     CHECK(sfdm.set("daq.instances.variables", instance_var1, &sc));
     CHECK(sfdm.set("daq.instances.variables", instance_var2, &sc));
 
-    CHECK(sfdm.end("daq.instances", 1, &sc));
+    CHECK(sfdm.end("daq.instances", 2, &sc));
+    CHECK(sfdm.end("daq.instances", 0, &sc));
     CHECK(sfdm.end("daq", 0, &sc));
 
     /* Validate the configuration */
index 4b25dab0b0c2b7fada435594bb144b062f49c54b..07a0323cf9fb826ea35af3e66b53fbb97d455651 100644 (file)
@@ -937,63 +937,41 @@ void AddVarToTable(SnortConfig* sc, const char* name, const char* value)
 //--------------------------------------------------------------------------
 
 #ifdef UNIT_TEST
+// FIXIT-L these var tests are inadequate
 
 TEST_CASE("config_set_var-success", "[vars]")
 {
-    SnortConfig* sc = new SnortConfig;
+    SnortConfig sc;
+    sc.var_list = NULL;
+    config_set_var(&sc, "A=B");
 
-    sc->var_list = NULL;
-
-    config_set_var(sc, "A=B");
-
-    REQUIRE(sc->var_list != NULL);
-    REQUIRE(sc->var_list->name != NULL);
-    REQUIRE(sc->var_list->value != NULL);
-    REQUIRE(*(sc->var_list->name) == 'A');
-    REQUIRE(*(sc->var_list->value) == 'B');
+    REQUIRE(sc.var_list->name[0] == 'A');
+    REQUIRE(sc.var_list->value[0] == 'B');
 }
 
 TEST_CASE("config_set_var-existing-success", "[vars]")
 {
-    SnortConfig* sc = new SnortConfig;
-    VarNode* vn1 = new VarNode;
-    VarNode* vn2 = new VarNode;
-
-    sc->var_list = vn1;
-    vn1->name = (char*)"C";
-    vn1->next = vn2;
-    vn2->name = (char*)"D";
-    vn2->next = NULL;
-
-    config_set_var(sc, "A=B");
-
-    REQUIRE(sc->var_list != NULL);
-    REQUIRE(sc->var_list->name != NULL);
-    REQUIRE(sc->var_list->value != NULL);
-    REQUIRE(*(sc->var_list->name) == 'A');
-    REQUIRE(*(sc->var_list->value) == 'B');
+    SnortConfig sc;
+
+    config_set_var(&sc, "C=D");
+    config_set_var(&sc, "A=B");
+
+    REQUIRE(sc.var_list->name[0] == 'A');
+    REQUIRE(sc.var_list->value[0] == 'B');
 }
 
+// FIXIT-L missing CHECKs / REQUIREs
 TEST_CASE("config_set_var-duplicate-error", "[vars]")
 {
-    SnortConfig* sc = new SnortConfig;
-    VarNode* vn1 = new VarNode;
-    VarNode* vn2 = new VarNode;
-
-    sc->var_list = vn1;
-    vn1->name = (char*)"C";
-    vn1->next = vn2;
-    vn2->name = (char*)"A";
-    vn2->next = NULL;
-
-    config_set_var(sc, "A=B");
+    SnortConfig sc;
+    config_set_var(&sc, "A=B");
 }
 
 TEST_CASE("config_set_var-no_equals_sign-error", "[vars]")
 {
-    SnortConfig* sc = new SnortConfig;
-
-    config_set_var(sc, "A");
+    SnortConfig sc;
+    config_set_var(&sc, "A");
 }
 
 #endif
+
index ef0eced4c262c01b46aae9e1314b178ab03e9e3e..b9fa496be9f46aa43f23b6b2a79b672b0ee50dbe 100644 (file)
@@ -286,6 +286,7 @@ const BaseApi* ips_stream_reassemble = &reassemble_api.base;
 
 #include "framework/cursor.h"
 
+// FIXIT-L these tests need some TLC
 TEST_CASE("IPS Stream Reassemble", "[ips_stream_reassemble][stream_tcp]")
 {
     // initialization code here
@@ -323,6 +324,10 @@ TEST_CASE("IPS Stream Reassemble", "[ips_stream_reassemble][stream_tcp]")
             == STREAM_FLPOLICY_IGNORE ) );
     }
 #endif
+    delete pkt->flow->session;
+    delete pkt;
+    delete flow;
+    ips_stream_reassemble->mod_dtor(reassembler);
 }
 
 #endif